On 4/25/25 9:10 PM, Kevin Traynor wrote:
> On 24/04/2025 12:30, Ilya Maximets wrote:
>> Some newer versions of GCC 15 complain:
>>
>> lib/uuid.c:308:40: error:
>> initializer-string for array of 'char' truncates NUL terminator but
>> destination lacks 'nonstring' attribute (37 chars into 36 available)
>> [-Werror=unterminated-string-initialization]
>>
>> static const char tmpl[UUID_LEN] = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> We could add 1 to the size or use the attribute, but it seems simpler
>> to just convert the template into a const string pointer. There
>> shouldn't be any practical difference as the string will be static
>> either way.
>>
>> It's not really a bug, the code is fine as it is, but adding a 'Fixes'
>> tag just as a reference for backports.
>>
>> Fixes: c80eac1f85df ("ovn-controller: Tie OpenFlow and logical flows using
>> OpenFlow cookie.")
>> Signed-off-by: Ilya Maximets <[email protected]>
>> ---
>> lib/uuid.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/uuid.c b/lib/uuid.c
>> index 8a16606da..e4caa0ec6 100644
>> --- a/lib/uuid.c
>> +++ b/lib/uuid.c
>> @@ -305,7 +305,7 @@ error:
>> int
>> uuid_is_partial_string(const char *s)
>> {
>> - static const char tmpl[UUID_LEN] =
>> "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
>> + const char *tmpl = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
>> size_t i;
>> for (i = 0; i < UUID_LEN; i++) {
>> if (s[i] == '\0') {
>
> Checked with gcc 15.0.1
>
> Acked-by: Kevin Traynor <[email protected]>
>
Thanks, Eelco and Kevin!
Applied to all supported branches down to 3.2.
Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev