[Xen-devel] Failing to build test-cpu-policy.c with GCC9

Dario Faggioli posted 1 patch 4 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/20ec48febe15d329547b0dc4fe1e411e0043c4df.camel@suse.com
Maintainers: "Roger Pau Monné" <roger.pau@citrix.com>, Jan Beulich <jbeulich@suse.com>, Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wl@xen.org>, Andrew Cooper <andrew.cooper3@citrix.com>
|
[Xen-devel] Failing to build test-cpu-policy.c with GCC9
Posted by Dario Faggioli 4 years, 9 months ago
Hey, Andy,

openSUSE Tumbleweed has: gcc version 9.1.1 20190703

And this fails to build test-cpu-policy.c, like this:

test-cpu-policy.c: In function ‘main’:
test-cpu-policy.c:64:18: error: ‘%.12s’ directive argument is not a nul-terminated string [-Werror=format-overflow=]
   64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-cpu-policy.c:20:12: note: in definition of macro ‘fail’
   20 |     printf(fmt, ##__VA_ARGS__);                 \
      |            ^~~
test-cpu-policy.c:64:27: note: format string is defined here
   64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
      |                           ^~~~~
test-cpu-policy.c:44:7: note: referenced argument declared here
   44 |     } tests[] = {
      |  

Even just doing something like below, seems to fix it for me, but there
probably are better ways...

Regards

---
diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-policy/test-cpu-policy.c
index ca3b8dd45f..e0c2c56154 100644
--- a/tools/tests/cpu-policy/test-cpu-policy.c
+++ b/tools/tests/cpu-policy/test-cpu-policy.c
@@ -35,7 +35,7 @@ static void test_vendor_identification(void)
 {
     static const struct test {
         union {
-            char ident[12];
+            char ident[13];
             struct {
                 uint32_t b, d, c;
             };
-- 
Dario Faggioli, Ph.D
http://about.me/dario.faggioli
Virtualization Software Engineer
SUSE Labs, SUSE https://www.suse.com/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] Failing to build test-cpu-policy.c with GCC9
Posted by Andrew Cooper 4 years, 9 months ago
On 26/07/2019 01:50, Dario Faggioli wrote:
> Hey, Andy,
>
> openSUSE Tumbleweed has: gcc version 9.1.1 20190703
>
> And this fails to build test-cpu-policy.c, like this:
>
> test-cpu-policy.c: In function ‘main’:
> test-cpu-policy.c:64:18: error: ‘%.12s’ directive argument is not a nul-terminated string [-Werror=format-overflow=]
>    64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
>       |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> test-cpu-policy.c:20:12: note: in definition of macro ‘fail’
>    20 |     printf(fmt, ##__VA_ARGS__);                 \
>       |            ^~~
> test-cpu-policy.c:64:27: note: format string is defined here
>    64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
>       |                           ^~~~~
> test-cpu-policy.c:44:7: note: referenced argument declared here
>    44 |     } tests[] = {
>       |  
>
> Even just doing something like below, seems to fix it for me, but there
> probably are better ways...

It's a compiler bug, but I haven't had time to file a ticket yet.

The claim in the warning is false.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel