[PATCH] Fix build warnings in resolv/res_send.c

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

[PATCH] Fix build warnings in resolv/res_send.c

Stefan Liebler-2
Hi,

this patch fixes the gcc warnings seen with gcc 9 -march>=z13 on s390x:
res_send.c: In function ‘__res_context_send’:
res_send.c:498:7: error: ‘resplen’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
   498 |    if (n == 0 && (buf2 == NULL || *resplen2 == 0))
       |       ^

In this case send_vc is inlined into __res_context_send
and the maybe uninitialized resplen belongs to the one in send_vc.

In send_vc there is already a DIAG_IGNORE_NEEDS_COMMENT (5,
"-Wmaybe-uninitialized")
and a comment which explains that this is a false-positive.
Note that resplen is used as return value.

This patch adds a further DIAG_IGNORE_NEEDS_COMMENT around the
declaration of n
in __res_context_send and the comparison after n was set to the return
value of send_vc.

Bye
Stefan

ChangeLog:

        * resolv/res_send.c (__res_context_send):
        Disable maybe-uninitialized warning.

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

Re: [PATCH] Fix build warnings in resolv/res_send.c

Stefan Liebler-2
On 6/25/19 3:18 PM, Stefan Liebler wrote:

> Hi,
>
> this patch fixes the gcc warnings seen with gcc 9 -march>=z13 on s390x:
> res_send.c: In function ‘__res_context_send’:
> res_send.c:498:7: error: ‘resplen’ may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
>    498 |    if (n == 0 && (buf2 == NULL || *resplen2 == 0))
>        |       ^
>
> In this case send_vc is inlined into __res_context_send
> and the maybe uninitialized resplen belongs to the one in send_vc.
>
> In send_vc there is already a DIAG_IGNORE_NEEDS_COMMENT (5,
> "-Wmaybe-uninitialized")
> and a comment which explains that this is a false-positive.
> Note that resplen is used as return value.
>
> This patch adds a further DIAG_IGNORE_NEEDS_COMMENT around the
> declaration of n
> in __res_context_send and the comparison after n was set to the return
> value of send_vc.
>
> Bye
> Stefan
>
> ChangeLog:
>
>      * resolv/res_send.c (__res_context_send):
>      Disable maybe-uninitialized warning.

ping

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix build warnings in resolv/res_send.c

DJ Delorie-2
In reply to this post by Stefan Liebler-2

Stefan Liebler <[hidden email]> writes:
> * resolv/res_send.c (__res_context_send):
> Disable maybe-uninitialized warning.

I think the compiler is getting to smart... but I agree with your logic
here.

LGTM.

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

Re: [PATCH] Fix build warnings in resolv/res_send.c

Stefan Liebler-2
On 7/1/19 7:35 PM, DJ Delorie wrote:

>
> Stefan Liebler <[hidden email]> writes:
>> * resolv/res_send.c (__res_context_send):
>> Disable maybe-uninitialized warning.
>
> I think the compiler is getting to smart... but I agree with your logic
> here.
>
> LGTM.
>
> Reviewed-by: DJ Delorie <[hidden email]>
>
Committed.
Thanks.