Re: [ovs-dev] [PATCH] tests: Fix build failure with Clang 18 due to -Wformat-truncation.

2024-04-30 Thread Ilya Maximets
On 4/30/24 13:12, Eelco Chaudron wrote:
> 
> 
> On 30 Apr 2024, at 11:53, Ilya Maximets wrote:
> 
>> On 4/26/24 18:35, Ilya Maximets wrote:
>>> Cirrus CI is broken on FreeBSD 13.3 due to clang version update.
>>> It now complains about snprintf truncation the same way GCC does:
>>>
>>>   tests/test-util.c:1129:16: error: 'snprintf' will always be truncated;
>>>   specified size is 5, but format string expands to at least 6
>>>   [-Werror,-Wformat-truncation]
>>>
>>>   1129 | ovs_assert(snprintf(s, 5, "abcde") == 5);
>>>|^
>>>
>>> Clang 17 on FreeBSD 14.0 works fine, but new Clang 18.1.4 on 13.3
>>> fails to build.
>>>
>>> Fix that by disabling Clang diagnostic the same way as we do for GCC.
>>>
>>> Unfortunately, the pragma's are compiler-specific, so cannot be
>>> combined, AFAIK.
>>>
>>> Signed-off-by: Ilya Maximets 
>>> ---
>>
>> Hi, Eelco and Simon.  May I ask you to take a look at this patch?
>>
>> It's blocking Cirrus CI and I don't think anything else should be
>> merged until CI is fixed.
>>
>> Best regards, Ilya Maximets.
> 
> Thanks Ilya, I agree! This looks good to me.
> 
> Acked-by: Eelco Chaudron 

Thanks, Eelco and Ales!  Applied to all branches down to 2.17.

Best regards, Ilya Maximets.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tests: Fix build failure with Clang 18 due to -Wformat-truncation.

2024-04-30 Thread Eelco Chaudron



On 30 Apr 2024, at 11:53, Ilya Maximets wrote:

> On 4/26/24 18:35, Ilya Maximets wrote:
>> Cirrus CI is broken on FreeBSD 13.3 due to clang version update.
>> It now complains about snprintf truncation the same way GCC does:
>>
>>   tests/test-util.c:1129:16: error: 'snprintf' will always be truncated;
>>   specified size is 5, but format string expands to at least 6
>>   [-Werror,-Wformat-truncation]
>>
>>   1129 | ovs_assert(snprintf(s, 5, "abcde") == 5);
>>|^
>>
>> Clang 17 on FreeBSD 14.0 works fine, but new Clang 18.1.4 on 13.3
>> fails to build.
>>
>> Fix that by disabling Clang diagnostic the same way as we do for GCC.
>>
>> Unfortunately, the pragma's are compiler-specific, so cannot be
>> combined, AFAIK.
>>
>> Signed-off-by: Ilya Maximets 
>> ---
>
> Hi, Eelco and Simon.  May I ask you to take a look at this patch?
>
> It's blocking Cirrus CI and I don't think anything else should be
> merged until CI is fixed.
>
> Best regards, Ilya Maximets.

Thanks Ilya, I agree! This looks good to me.

Acked-by: Eelco Chaudron 


>>  tests/test-util.c | 13 ++---
>>  1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/tests/test-util.c b/tests/test-util.c
>> index 7d899fbbf..5d88d38f2 100644
>> --- a/tests/test-util.c
>> +++ b/tests/test-util.c
>> @@ -1116,12 +1116,16 @@ test_snprintf(struct ovs_cmdl_context *ctx 
>> OVS_UNUSED)
>>  {
>>  char s[16];
>>
>> +/* GCC 7+ and Clang 18+ warn about the following calls that truncate
>> + * a string using snprintf().  We're testing that truncation works
>> + * properly, so temporarily disable the warning. */
>>  #if __GNUC__ >= 7
>> -/* GCC 7+ warns about the following calls that truncate a string using
>> - * snprintf().  We're testing that truncation works properly, so
>> - * temporarily disable the warning. */
>>  #pragma GCC diagnostic push
>>  #pragma GCC diagnostic ignored "-Wformat-truncation"
>> +#endif
>> +#if __clang_major__ >= 18
>> +#pragma clang diagnostic push
>> +#pragma clang diagnostic ignored "-Wformat-truncation"
>>  #endif
>>  ovs_assert(snprintf(s, 4, "abcde") == 5);
>>  ovs_assert(!strcmp(s, "abc"));
>> @@ -1130,6 +1134,9 @@ test_snprintf(struct ovs_cmdl_context *ctx OVS_UNUSED)
>>  ovs_assert(!strcmp(s, "abcd"));
>>  #if __GNUC__ >= 7
>>  #pragma GCC diagnostic pop
>> +#endif
>> +#if __clang_major__ >= 18
>> +#pragma clang diagnostic pop
>>  #endif
>>
>>  ovs_assert(snprintf(s, 6, "abcde") == 5);

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tests: Fix build failure with Clang 18 due to -Wformat-truncation.

2024-04-30 Thread Ales Musil
On Fri, Apr 26, 2024 at 6:35 PM Ilya Maximets  wrote:

> Cirrus CI is broken on FreeBSD 13.3 due to clang version update.
> It now complains about snprintf truncation the same way GCC does:
>
>   tests/test-util.c:1129:16: error: 'snprintf' will always be truncated;
>   specified size is 5, but format string expands to at least 6
>   [-Werror,-Wformat-truncation]
>
>   1129 | ovs_assert(snprintf(s, 5, "abcde") == 5);
>|^
>
> Clang 17 on FreeBSD 14.0 works fine, but new Clang 18.1.4 on 13.3
> fails to build.
>
> Fix that by disabling Clang diagnostic the same way as we do for GCC.
>
> Unfortunately, the pragma's are compiler-specific, so cannot be
> combined, AFAIK.
>
> Signed-off-by: Ilya Maximets 
> ---
>  tests/test-util.c | 13 ++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/tests/test-util.c b/tests/test-util.c
> index 7d899fbbf..5d88d38f2 100644
> --- a/tests/test-util.c
> +++ b/tests/test-util.c
> @@ -1116,12 +1116,16 @@ test_snprintf(struct ovs_cmdl_context *ctx
> OVS_UNUSED)
>  {
>  char s[16];
>
> +/* GCC 7+ and Clang 18+ warn about the following calls that truncate
> + * a string using snprintf().  We're testing that truncation works
> + * properly, so temporarily disable the warning. */
>  #if __GNUC__ >= 7
> -/* GCC 7+ warns about the following calls that truncate a string using
> - * snprintf().  We're testing that truncation works properly, so
> - * temporarily disable the warning. */
>  #pragma GCC diagnostic push
>  #pragma GCC diagnostic ignored "-Wformat-truncation"
> +#endif
> +#if __clang_major__ >= 18
> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Wformat-truncation"
>  #endif
>  ovs_assert(snprintf(s, 4, "abcde") == 5);
>  ovs_assert(!strcmp(s, "abc"));
> @@ -1130,6 +1134,9 @@ test_snprintf(struct ovs_cmdl_context *ctx
> OVS_UNUSED)
>  ovs_assert(!strcmp(s, "abcd"));
>  #if __GNUC__ >= 7
>  #pragma GCC diagnostic pop
> +#endif
> +#if __clang_major__ >= 18
> +#pragma clang diagnostic pop
>  #endif
>
>  ovs_assert(snprintf(s, 6, "abcde") == 5);
> --
> 2.44.0
>
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
Looks good to me, thanks.

Acked-by: Ales Musil 
-- 

Ales Musil

Senior Software Engineer - OVN Core

Red Hat EMEA 

amu...@redhat.com

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tests: Fix build failure with Clang 18 due to -Wformat-truncation.

2024-04-30 Thread Ilya Maximets
On 4/26/24 18:35, Ilya Maximets wrote:
> Cirrus CI is broken on FreeBSD 13.3 due to clang version update.
> It now complains about snprintf truncation the same way GCC does:
> 
>   tests/test-util.c:1129:16: error: 'snprintf' will always be truncated;
>   specified size is 5, but format string expands to at least 6
>   [-Werror,-Wformat-truncation]
> 
>   1129 | ovs_assert(snprintf(s, 5, "abcde") == 5);
>|^
> 
> Clang 17 on FreeBSD 14.0 works fine, but new Clang 18.1.4 on 13.3
> fails to build.
> 
> Fix that by disabling Clang diagnostic the same way as we do for GCC.
> 
> Unfortunately, the pragma's are compiler-specific, so cannot be
> combined, AFAIK.
> 
> Signed-off-by: Ilya Maximets 
> ---

Hi, Eelco and Simon.  May I ask you to take a look at this patch?

It's blocking Cirrus CI and I don't think anything else should be
merged until CI is fixed.

Best regards, Ilya Maximets.


>  tests/test-util.c | 13 ++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/test-util.c b/tests/test-util.c
> index 7d899fbbf..5d88d38f2 100644
> --- a/tests/test-util.c
> +++ b/tests/test-util.c
> @@ -1116,12 +1116,16 @@ test_snprintf(struct ovs_cmdl_context *ctx OVS_UNUSED)
>  {
>  char s[16];
>  
> +/* GCC 7+ and Clang 18+ warn about the following calls that truncate
> + * a string using snprintf().  We're testing that truncation works
> + * properly, so temporarily disable the warning. */
>  #if __GNUC__ >= 7
> -/* GCC 7+ warns about the following calls that truncate a string using
> - * snprintf().  We're testing that truncation works properly, so
> - * temporarily disable the warning. */
>  #pragma GCC diagnostic push
>  #pragma GCC diagnostic ignored "-Wformat-truncation"
> +#endif
> +#if __clang_major__ >= 18
> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Wformat-truncation"
>  #endif
>  ovs_assert(snprintf(s, 4, "abcde") == 5);
>  ovs_assert(!strcmp(s, "abc"));
> @@ -1130,6 +1134,9 @@ test_snprintf(struct ovs_cmdl_context *ctx OVS_UNUSED)
>  ovs_assert(!strcmp(s, "abcd"));
>  #if __GNUC__ >= 7
>  #pragma GCC diagnostic pop
> +#endif
> +#if __clang_major__ >= 18
> +#pragma clang diagnostic pop
>  #endif
>  
>  ovs_assert(snprintf(s, 6, "abcde") == 5);

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tests: Fix build failure with Clang 18 due to -Wformat-truncation.

2024-04-29 Thread Ilya Maximets
On 4/26/24 18:35, Ilya Maximets wrote:
> Cirrus CI is broken on FreeBSD 13.3 due to clang version update.
> It now complains about snprintf truncation the same way GCC does:
> 
>   tests/test-util.c:1129:16: error: 'snprintf' will always be truncated;
>   specified size is 5, but format string expands to at least 6
>   [-Werror,-Wformat-truncation]
> 
>   1129 | ovs_assert(snprintf(s, 5, "abcde") == 5);
>|^
> 
> Clang 17 on FreeBSD 14.0 works fine, but new Clang 18.1.4 on 13.3
> fails to build.
> 
> Fix that by disabling Clang diagnostic the same way as we do for GCC.
> 
> Unfortunately, the pragma's are compiler-specific, so cannot be
> combined, AFAIK.
> 
> Signed-off-by: Ilya Maximets 
> ---


Recheck-request: github-robot
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tests: Fix build failure with Clang 18 due to -Wformat-truncation.

2024-04-26 Thread Ilya Maximets
On 4/26/24 18:35, Ilya Maximets wrote:
> Cirrus CI is broken on FreeBSD 13.3 due to clang version update.
> It now complains about snprintf truncation the same way GCC does:
> 
>   tests/test-util.c:1129:16: error: 'snprintf' will always be truncated;
>   specified size is 5, but format string expands to at least 6
>   [-Werror,-Wformat-truncation]
> 
>   1129 | ovs_assert(snprintf(s, 5, "abcde") == 5);
>|^
> 
> Clang 17 on FreeBSD 14.0 works fine, but new Clang 18.1.4 on 13.3
> fails to build.
> 
> Fix that by disabling Clang diagnostic the same way as we do for GCC.
> 
> Unfortunately, the pragma's are compiler-specific, so cannot be
> combined, AFAIK.
> 
> Signed-off-by: Ilya Maximets 
> ---

The issue affects both Fedora Rawhide and Ubuntu 24.03 as well.

Interestingly, Fedora Rawhide throws one more warning in a different
area, even though the clang version in it is 18.1.3 and it is the
same as in Ubuntu.

Will address that other warning separately.

>  tests/test-util.c | 13 ++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/test-util.c b/tests/test-util.c
> index 7d899fbbf..5d88d38f2 100644
> --- a/tests/test-util.c
> +++ b/tests/test-util.c
> @@ -1116,12 +1116,16 @@ test_snprintf(struct ovs_cmdl_context *ctx OVS_UNUSED)
>  {
>  char s[16];
>  
> +/* GCC 7+ and Clang 18+ warn about the following calls that truncate
> + * a string using snprintf().  We're testing that truncation works
> + * properly, so temporarily disable the warning. */
>  #if __GNUC__ >= 7
> -/* GCC 7+ warns about the following calls that truncate a string using
> - * snprintf().  We're testing that truncation works properly, so
> - * temporarily disable the warning. */
>  #pragma GCC diagnostic push
>  #pragma GCC diagnostic ignored "-Wformat-truncation"
> +#endif
> +#if __clang_major__ >= 18
> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Wformat-truncation"
>  #endif
>  ovs_assert(snprintf(s, 4, "abcde") == 5);
>  ovs_assert(!strcmp(s, "abc"));
> @@ -1130,6 +1134,9 @@ test_snprintf(struct ovs_cmdl_context *ctx OVS_UNUSED)
>  ovs_assert(!strcmp(s, "abcd"));
>  #if __GNUC__ >= 7
>  #pragma GCC diagnostic pop
> +#endif
> +#if __clang_major__ >= 18
> +#pragma clang diagnostic pop
>  #endif
>  
>  ovs_assert(snprintf(s, 6, "abcde") == 5);

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev