12 Star 0 Fork 71

src-openEuler/coreutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
coreutils-9.5-gcc14-gnulib-lto.patch 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
From 4602765093f04e597f87d78cf29d21eea03b6fa4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Wed, 28 Aug 2024 12:10:43 +0100
Subject: avoid GCC -Wmaybe-uninitialized false positives with LTO
Avoids false warnings with GCC 14.2.1 with -flto
* lib/canonicalize.c: Initialize END_IDX.
* lib/getndelim2.c: Initialize C.
---
ChangeLog | 8 ++++++++
lib/canonicalize.c | 9 ++++++++-
lib/getndelim2.c | 8 +++++---
3 files changed, 21 insertions(+), 4 deletions(-)
--- a/lib/canonicalize.c
+++ b/lib/canonicalize.c
@@ -34,6 +34,13 @@
#include "hash-triple.h"
#include "xalloc.h"
+/* Suppress bogus GCC -Wmaybe-uninitialized warnings. */
+#if defined GCC_LINT || defined lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
# define DOUBLE_SLASH_IS_DISTINCT_ROOT false
#endif
@@ -367,7 +374,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
buf[n] = '\0';
char *extra_buf = bufs->extra.data;
- idx_t end_idx;
+ idx_t end_idx IF_LINT (= 0);
if (end_in_extra_buffer)
end_idx = end - extra_buf;
size_t len = strlen (end);
diff --git a/lib/getndelim2.c b/lib/getndelim2.c
index 89989ae..db61e2a 100644
--- a/lib/getndelim2.c
+++ b/lib/getndelim2.c
@@ -47,8 +47,10 @@
#include "memchr2.h"
/* Avoid false GCC warning "'c' may be used uninitialized". */
-#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4
-# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#if defined GCC_LINT || defined lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
#endif
/* The maximum value that getndelim2 can return without suffering from
@@ -102,7 +104,7 @@ getndelim2 {
/* Here always ptr + size == read_pos + nbytes_avail.
Also nbytes_avail > 0 || size < nmax. */
- int c;
+ int c IF_LINT (= EOF);
const char *buffer;
size_t buffer_len;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/coreutils.git
git@gitee.com:src-openeuler/coreutils.git
src-openeuler
coreutils
coreutils
master

搜索帮助