summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-12-31 20:48:53 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2022-12-31 21:01:30 -0800
commit28e4de2c641df42e0707609b96c62466bd562d1b (patch)
treeb22845392ea37c7787cb0e7dfecf85eb1ecd3bbc
parent73799908453a5ef96bf80843668653f0229ad76f (diff)
downloaddiffutils-28e4de2c641df42e0707609b96c62466bd562d1b.tar.gz
build: simplify GCC 12 false alarm workaround
* src/util.c (print_message_queue): Pacify GCC in a more-straightforward way.
-rw-r--r--src/util.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/util.c b/src/util.c
index e4d7240..956083c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -153,13 +153,6 @@ message (char const *format_msgid, ...)
va_end (ap);
}
-/* Suppress false positive from gcc version 13.0.0 20221208 (experimental) (GCC)
- */
-_Pragma ("GCC diagnostic push")
-#if 12 <= __GNUC__
-_Pragma ("GCC diagnostic ignored \"-Wanalyzer-use-of-uninitialized-value\"")
-#endif
-
/* Output all the messages that were saved up by calls to 'message'. */
void
@@ -170,14 +163,13 @@ print_message_queue (void)
/* Change this if diff ever has messages with more than 4 args. */
char const *p = m->args;
char const *plim = p + m->argbytes;
- char const *arg[4];
- for (int i = 0; i < 4; i++)
- {
- arg[i] = p;
- if (p < plim)
- p += strlen (p) + 1;
- }
- printf (_(m->msgid), arg[0], arg[1], arg[2], arg[3]);
+ /* Unroll the loop to work around GCC 12 bug with
+ -Wanalyzer-use-of-uninitialized-value. */
+ char const *arg0 = p; p += p < plim ? strlen (p) + 1 : 0;
+ char const *arg1 = p; p += p < plim ? strlen (p) + 1 : 0;
+ char const *arg2 = p; p += p < plim ? strlen (p) + 1 : 0;
+ char const *arg3 = p; p += p < plim ? strlen (p) + 1 : 0;
+ printf (_(m->msgid), arg0, arg1, arg2, arg3);
if (p < plim)
abort ();
struct msg *next = m->next;
@@ -185,7 +177,6 @@ print_message_queue (void)
m = next;
}
}
-_Pragma ("GCC diagnostic pop")
/* Signal handling, needed for restoring default colors. */