x86/cpu-policy: work around bogus warning in test harness
authorJan Beulich <jbeulich@suse.com>
Thu, 5 Sep 2019 08:00:07 +0000 (10:00 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 5 Sep 2019 08:00:07 +0000 (10:00 +0200)
commitaa370d3c26d2899ffe950849504edfdfb79400ea
tree4ff46a624ec5915284f42b60502b84bd0da67a03
parent43f0009984a5b1dfb42ab216006ddd26086b7072
x86/cpu-policy: work around bogus warning in test harness

Despite %.12s properly limiting the number of characters read from
ident[], gcc 9 (at least up to 9.2.0) warns about the strings not
being nul-terminated:

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[] = {
      |       ^~~~~

The issue was reported against gcc in their bugzilla (bug 91667).

Re-order array entries, oddly enough suppressing the warning.

Reported-by: Christopher Clark <christopher.w.clark@gmail.com>
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/tests/cpu-policy/test-cpu-policy.c