On 09/08/2019 12:34, Jan Beulich wrote: > On 09.08.2019 13:05, Ian Jackson wrote: >> Jan Beulich writes ("Re: [Xen-devel] [PATCH 2/2] >> tools/tests/cpu-policy: disable -Wformat-overflow"): >>> Would you mind clarifying which 12 you mean to change to 13? >>> The one in "%.12s" would, if changed and afaict, then >>> legitimately trigger the warning. And we've already objected >>> to the array to get grown. >> >> I meant the array. I missed that objection. I just went and read the >> thread >> tests/cpu-policy: fix format-overflow warning by null terminating >> strings >> and it did conclude that the compiler was wrong to complain. >> >> But for me it doesn't follow that the original code is necessarily the >> best way of doing things, and I didn't see anyone giving an argument >> why simply increasing the array was a bad idea. >> >> C "prefers" null-terminated strings in that they work somewhat better >> with a variety of primitives. > > Right, but the %.<num>s specification exits precisely to allow > to deal with potentially not nul-terminated strings. ACPI code > in the hypervisor makes quite a bit of use of this, for example, > without triggering any compiler warnings with 9.1.0.
I also wonder whether https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-nonstring-variable-attribute might be a way of fixing this, seeing as it exists specifically for the purpose. ~Andrew _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel