qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 6/6] qemu-io-cmds: Silent GCC9 format-overflow warning


From: Philippe Mathieu-Daudé
Subject: [PATCH 6/6] qemu-io-cmds: Silent GCC9 format-overflow warning
Date: Tue, 17 Dec 2019 18:34:25 +0100

GCC9 is confused when building with CFLAG -O3:

  In function ‘help_oneline’,
      inlined from ‘help_all’ at qemu-io-cmds.c:2414:9,
      inlined from ‘help_f’ at qemu-io-cmds.c:2424:9:
  qemu-io-cmds.c:2389:9: error: ‘%s’ directive argument is null 
[-Werror=format-overflow=]
   2389 |         printf("%s ", ct->name);
        |         ^~~~~~~~~~~~~~~~~~~~~~~

Audit shows this can't happen. Give a hint to GCC adding an
assert() call.

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
Cc: Kevin Wolf <address@hidden>
Cc: Max Reitz <address@hidden>
Cc: address@hidden
---
 qemu-io-cmds.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 1b7e700020..9e956a5dd4 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -2411,6 +2411,7 @@ static void help_all(void)
     const cmdinfo_t *ct;
 
     for (ct = cmdtab; ct < &cmdtab[ncmds]; ct++) {
+        assert(ct->name);
         help_oneline(ct->name, ct);
     }
     printf("\nUse 'help commandname' for extended help.\n");
-- 
2.21.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]