[PATCH] Fix gcc 9 build errors for make xcheck.

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Fix gcc 9 build errors for make xcheck.

Stefan Liebler-2
Hi,

this patch fixes the following gcc 9 warnings for "make xcheck":
-string/tst-strcasestr.c:
../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive
argument is null [-Werror=format-overflow=]

-argp/argp-test.c:
argp-test.c:130:20: error: ‘%d’ directive writing between 1 and 11 bytes
into a region of size 10 [-Werror=format-overflow=]
argp-test.c:130:19: note: directive argument in the range [-2147483648, 122]
argp-test.c:130:5: note: ‘sprintf’ output between 2 and 12 bytes into a
destination of size 10

-nss/tst-field.c:
tst-field.c:52:7: error: ‘%s’ directive argument is null
[-Werror=format-overflow=]

Bye
Stefan

ChangeLog:

        * string/test-strcasestr.c (check_result): Add NULL check.
        * nss/tst-field.c (check_rewrite): Likewise.
        * argp/argp-test.c (popt): Increase size of buf to 12.

20190614_gcc9warnings.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Yann Droneaud
Hi,

Le lundi 17 juin 2019 à 08:35 +0200, Stefan Liebler a écrit :
>
> this patch fixes the following gcc 9 warnings for "make xcheck":
> -string/tst-strcasestr.c:
> ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive
> argument is null [-Werror=format-overflow=]
>

This was reported as bug #24556

https://sourceware.org/bugzilla/show_bug.cgi?id=24556

Regards.

--
Yann Droneaud
OPTEYA


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Stefan Liebler-2
On 6/17/19 10:54 AM, Yann Droneaud wrote:

> Hi,
>
> Le lundi 17 juin 2019 à 08:35 +0200, Stefan Liebler a écrit :
>>
>> this patch fixes the following gcc 9 warnings for "make xcheck":
>> -string/tst-strcasestr.c:
>> ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive
>> argument is null [-Werror=format-overflow=]
>>
>
> This was reported as bug #24556
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=24556
>
> Regards.
>
Thanks for this hint.
I've updated the patch and I'm now able to run "make xcheck" and "make
bench" with gcc 9.

Bye
Stefan

20190617_1245_gcc9warnings.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Andreas Schwab
On Jun 17 2019, Stefan Liebler <[hidden email]> wrote:

> diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c
> index 2cbe13e9ac..14053e7a22 100644
> --- a/benchtests/bench-strstr.c
> +++ b/benchtests/bench-strstr.c
> @@ -147,7 +147,7 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
>    if (res != exp_result)
>      {
>        error (0, 0, "Wrong result in function %s %s %s", impl->name,
> -     res, exp_result);
> +     res, (exp_result == NULL) ? "NULL" : exp_result);

res can be NULL too.

> diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c
> index 0a16f85dcd..1773581a3e 100644
> --- a/string/test-strcasestr.c
> +++ b/string/test-strcasestr.c
> @@ -67,7 +67,7 @@ check_result (impl_t *impl, const char *s1, const char *s2,
>    if (result != exp_result)
>      {
>        error (0, 0, "Wrong result in function %s %s %s", impl->name,
> -     result, exp_result);
> +     result, (exp_result == NULL) ? "NULL" : exp_result);

result can be NULL too.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Stefan Liebler-2
On 6/17/19 4:07 PM, Andreas Schwab wrote:

> On Jun 17 2019, Stefan Liebler <[hidden email]> wrote:
>
>> diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c
>> index 2cbe13e9ac..14053e7a22 100644
>> --- a/benchtests/bench-strstr.c
>> +++ b/benchtests/bench-strstr.c
>> @@ -147,7 +147,7 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
>>     if (res != exp_result)
>>       {
>>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>> -     res, exp_result);
>> +     res, (exp_result == NULL) ? "NULL" : exp_result);
>
> res can be NULL too.
>
>> diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c
>> index 0a16f85dcd..1773581a3e 100644
>> --- a/string/test-strcasestr.c
>> +++ b/string/test-strcasestr.c
>> @@ -67,7 +67,7 @@ check_result (impl_t *impl, const char *s1, const char *s2,
>>     if (result != exp_result)
>>       {
>>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>> -     result, exp_result);
>> +     result, (exp_result == NULL) ? "NULL" : exp_result);
>
> result can be NULL too.
>
> Andreas.
>

That's true.
The compiler does not emit a warning for those.
Shall we nevertheless add a check?

Bye
Stefan

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Andreas Schwab
On Jun 17 2019, Stefan Liebler <[hidden email]> wrote:

> On 6/17/19 4:07 PM, Andreas Schwab wrote:
>> On Jun 17 2019, Stefan Liebler <[hidden email]> wrote:
>>
>>> diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c
>>> index 2cbe13e9ac..14053e7a22 100644
>>> --- a/benchtests/bench-strstr.c
>>> +++ b/benchtests/bench-strstr.c
>>> @@ -147,7 +147,7 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
>>>     if (res != exp_result)
>>>       {
>>>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>>> -     res, exp_result);
>>> +     res, (exp_result == NULL) ? "NULL" : exp_result);
>>
>> res can be NULL too.
>>
>>> diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c
>>> index 0a16f85dcd..1773581a3e 100644
>>> --- a/string/test-strcasestr.c
>>> +++ b/string/test-strcasestr.c
>>> @@ -67,7 +67,7 @@ check_result (impl_t *impl, const char *s1, const char *s2,
>>>     if (result != exp_result)
>>>       {
>>>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>>> -     result, exp_result);
>>> +     result, (exp_result == NULL) ? "NULL" : exp_result);
>>
>> result can be NULL too.
>>
>> Andreas.
>>
>
> That's true.
> The compiler does not emit a warning for those.
> Shall we nevertheless add a check?

Either check both or none.  If NULL is a problem then it needs to be
checked everywhere.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Stefan Liebler-2
On 6/17/19 4:59 PM, Andreas Schwab wrote:

> On Jun 17 2019, Stefan Liebler <[hidden email]> wrote:
>
>> On 6/17/19 4:07 PM, Andreas Schwab wrote:
>>> On Jun 17 2019, Stefan Liebler <[hidden email]> wrote:
>>>
>>>> diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c
>>>> index 2cbe13e9ac..14053e7a22 100644
>>>> --- a/benchtests/bench-strstr.c
>>>> +++ b/benchtests/bench-strstr.c
>>>> @@ -147,7 +147,7 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
>>>>      if (res != exp_result)
>>>>        {
>>>>          error (0, 0, "Wrong result in function %s %s %s", impl->name,
>>>> -     res, exp_result);
>>>> +     res, (exp_result == NULL) ? "NULL" : exp_result);
>>>
>>> res can be NULL too.
>>>
>>>> diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c
>>>> index 0a16f85dcd..1773581a3e 100644
>>>> --- a/string/test-strcasestr.c
>>>> +++ b/string/test-strcasestr.c
>>>> @@ -67,7 +67,7 @@ check_result (impl_t *impl, const char *s1, const char *s2,
>>>>      if (result != exp_result)
>>>>        {
>>>>          error (0, 0, "Wrong result in function %s %s %s", impl->name,
>>>> -     result, exp_result);
>>>> +     result, (exp_result == NULL) ? "NULL" : exp_result);
>>>
>>> result can be NULL too.
>>>
>>> Andreas.
>>>
>>
>> That's true.
>> The compiler does not emit a warning for those.
>> Shall we nevertheless add a check?
>
> Either check both or none.  If NULL is a problem then it needs to be
> checked everywhere.
>
> Andreas.
>
Okay I've added the two mentioned occurrences and also added checks in
string/test-strstr.c.

Bye
Stefan

20190617_1755_gcc9warnings.patch (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

DJ Delorie-2

Stefan Liebler <[hidden email]> writes:
>     tst-field.c:52:7: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
>      Please enter the commit message for your changes. Lines starting

Heh, double check your commit message :-)

> -  char buf[10];
> +  char buf[12];

-MAXINT would be "-2147483648\0" - 12 bytes.  Ok.

> -  for (int t = 0; t <= 3; t++)
> +  for (int t = 0; t < 3; t++)

Corresponds to:
static malloc_args tests[3][NUM_ALLOCS];

So OK.

>        error (0, 0, "Wrong result in function %s %s %s", impl->name,
> -     res, exp_result);
> +     (res == NULL) ? "NULL" : res,
> +     (exp_result == NULL) ? "NULL" : exp_result);

Ok.  Do we have a standard for printing NULL?  I mean, other unix's
print "(null)" for example.  If we're changing it anyway, a bit of
consistency would be nice.  But OK anyway :-)

>        printf ("FAIL: rewrite \"%s\" -> \"%s\", expected \"%s\"\n",
> -      input, result, expected);
> +      (input == NULL) ? "NULL" : input, result, expected);

We explicitly pass NULL for input at least once, so OK.  We never pass
NULL for expected, but as for test-strcasestr.c, we should protect it
anyway.  We test for result!=NULL so do not need to check that one.

>        error (0, 0, "Wrong result in function %s %s %s", impl->name,
> -     result, exp_result);
> +     (result == NULL) ? "NULL" : result,
> +     (exp_result == NULL) ? "NULL" : exp_result);

Ok.

>        error (0, 0, "Wrong result in function %s %s %s", impl->name,
> -     result, exp_result);
> +     (result == NULL) ? "NULL" : result,
> +     (exp_result == NULL) ? "NULL" : exp_result);

Ok.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Stefan Liebler-2
On 6/17/19 8:11 PM, DJ Delorie wrote:
>
> Stefan Liebler <[hidden email]> writes:
>>      tst-field.c:52:7: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
>>       Please enter the commit message for your changes. Lines starting
>
> Heh, double check your commit message :-)
:-) Removed.

>
>> -  char buf[10];
>> +  char buf[12];
>
> -MAXINT would be "-2147483648\0" - 12 bytes.  Ok.
>
>> -  for (int t = 0; t <= 3; t++)
>> +  for (int t = 0; t < 3; t++)
>
> Corresponds to:
> static malloc_args tests[3][NUM_ALLOCS];
>
> So OK.
>
>>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>> -     res, exp_result);
>> +     (res == NULL) ? "NULL" : res,
>> +     (exp_result == NULL) ? "NULL" : exp_result);
>
> Ok.  Do we have a standard for printing NULL?  I mean, other unix's
> print "(null)" for example.  If we're changing it anyway, a bit of
> consistency would be nice.  But OK anyway :-)
Changed all to "(NULL)".
>
>>         printf ("FAIL: rewrite \"%s\" -> \"%s\", expected \"%s\"\n",
>> -      input, result, expected);
>> +      (input == NULL) ? "NULL" : input, result, expected);
>
> We explicitly pass NULL for input at least once, so OK.  We never pass
> NULL for expected, but as for test-strcasestr.c, we should protect it
> anyway.  We test for result!=NULL so do not need to check that one.
Yes, it does not hurt. Added this check.

> >>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>> -     result, exp_result);
>> +     (result == NULL) ? "NULL" : result,
>> +     (exp_result == NULL) ? "NULL" : exp_result);
>
> Ok.
>
>>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>> -     result, exp_result);
>> +     (result == NULL) ? "NULL" : result,
>> +     (exp_result == NULL) ? "NULL" : exp_result);
>
> Ok.
>
Bye
Stefan

20190618_0935_gcc9warnings.patch (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Andreas Schwab
On Jun 18 2019, Stefan Liebler <[hidden email]> wrote:

>>>         error (0, 0, "Wrong result in function %s %s %s", impl->name,
>>> -     res, exp_result);
>>> +     (res == NULL) ? "NULL" : res,
>>> +     (exp_result == NULL) ? "NULL" : exp_result);
>>
>> Ok.  Do we have a standard for printing NULL?  I mean, other unix's
>> print "(null)" for example.  If we're changing it anyway, a bit of
>> consistency would be nice.  But OK anyway :-)
> Changed all to "(NULL)".

printf uses "(null)".

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Stefan Liebler-2
On 6/18/19 10:39 AM, Andreas Schwab wrote:

> On Jun 18 2019, Stefan Liebler <[hidden email]> wrote:
>
>>>>          error (0, 0, "Wrong result in function %s %s %s", impl->name,
>>>> -     res, exp_result);
>>>> +     (res == NULL) ? "NULL" : res,
>>>> +     (exp_result == NULL) ? "NULL" : exp_result);
>>>
>>> Ok.  Do we have a standard for printing NULL?  I mean, other unix's
>>> print "(null)" for example.  If we're changing it anyway, a bit of
>>> consistency would be nice.  But OK anyway :-)
>> Changed all to "(NULL)".
>
> printf uses "(null)".
Changed all to "(null)"
>
> Andreas.
>

Bye
Stefan

20190618_1050_gcc9warnings.patch (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

DJ Delorie-2

LGTM
Reviewed-by: DJ Delorie <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix gcc 9 build errors for make xcheck.

Stefan Liebler-2
On 6/18/19 7:48 PM, DJ Delorie wrote:
>
> LGTM
> Reviewed-by: DJ Delorie <[hidden email]>
>

Pushed and closed the bugzilla.

Thanks.
Stefan