On 25/07/2019 11:03, Jan Beulich wrote:
> On 25.07.2019 02:53, [email protected] wrote:
>> gcc 9.1.0 reports:
>>
>> | 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[] = {
>> |       |       ^~~~~
> I must be missing something here: %.12s says that no more than 12
> bytes are to be read from the string. There's nul terminator
> required. This is what the standard says
>
> "Characters from the array are written up to (but not including)
>   the terminating null character. If the precision is specified, no
>   more than that many bytes are written. If the precision is not
>   specified or is greater than the size of the array, the array
>   shall contain a null character."
>
> For the moment it looks to me as if the compiler was wrong to
> complain.

That is my assessment as well, but I haven't had time to file a GCC bug yet.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to