1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
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/gnulib/lib/canonicalize.c
+++ b/gnulib/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/gnulib/lib/getndelim2.c
+++ b/gnulib/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;
|