diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2022-12-31 20:48:53 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2022-12-31 21:01:30 -0800 |
commit | 28e4de2c641df42e0707609b96c62466bd562d1b (patch) | |
tree | b22845392ea37c7787cb0e7dfecf85eb1ecd3bbc | |
parent | 73799908453a5ef96bf80843668653f0229ad76f (diff) | |
download | diffutils-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.c | 23 |
1 files changed, 7 insertions, 16 deletions
@@ -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. */ |