Get rid of Werror=maybe-uninitialized in res_send.c.

Message ID 03d65724-d69b-d553-18a5-dece072e5a45@linux.ibm.com
State New
Headers show
Series
  • Get rid of Werror=maybe-uninitialized in res_send.c.
Related show

Commit Message

Stefan Liebler Dec. 3, 2019, 8:50 a.m.
Hi,

the commit 446997ff1433d33452b81dfa9e626b8dccf101a4 introduced
this new usage of resplen. If build with gcc 9 -march>=z13 on s390x,
the following warning occurs:
res_send.c: In function ‘__res_context_send’:
res_send.c:539:6: error: ‘resplen’ may be used uninitialized in this 
function [-Werror=maybe-uninitialized]
539 |   if (resplen > HFIXEDSZ)
|      ^

Therefore this patch adds a further DIAG_IGNORE_NEEDS_COMMENT in the
same way as it was previously done for usages of resplen or n.
See commit d1bc2cbbed9aea2017ef941f63c8786571da5b4f.

Bye
Stefan

Comments

Stefan Liebler Dec. 9, 2019, 1 p.m. | #1
On 12/3/19 9:50 AM, Stefan Liebler wrote:
> Hi,

> 

> the commit 446997ff1433d33452b81dfa9e626b8dccf101a4 introduced

> this new usage of resplen. If build with gcc 9 -march>=z13 on s390x,

> the following warning occurs:

> res_send.c: In function ‘__res_context_send’:

> res_send.c:539:6: error: ‘resplen’ may be used uninitialized in this 

> function [-Werror=maybe-uninitialized]

> 539 |   if (resplen > HFIXEDSZ)

> |      ^

> 

> Therefore this patch adds a further DIAG_IGNORE_NEEDS_COMMENT in the

> same way as it was previously done for usages of resplen or n.

> See commit d1bc2cbbed9aea2017ef941f63c8786571da5b4f.

> 

> Bye

> Stefan


ping

Patch

commit bfd6a9fcd4fbbd19eb67b868a27f83c801e2e725
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Mon Dec 2 13:11:52 2019 +0100

    Get rid of Werror=maybe-uninitialized in res_send.c.
    
    The commit 446997ff1433d33452b81dfa9e626b8dccf101a4 introduced
    this new usage of resplen. If build with gcc 9 -march>=z13 on s390x,
    the following warning occurs:
    res_send.c: In function ‘__res_context_send’:
    res_send.c:539:6: error: ‘resplen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      539 |   if (resplen > HFIXEDSZ)
          |      ^
    
    Therefore this patch adds a further DIAG_IGNORE_NEEDS_COMMENT in the
    same way as it was previously done for usages of resplen or n.
    See commit d1bc2cbbed9aea2017ef941f63c8786571da5b4f.

diff --git a/resolv/res_send.c b/resolv/res_send.c
index fce810031f..975985f13a 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -534,6 +534,9 @@  __res_context_send (struct resolv_context *ctx,
 
 		resplen = n;
 
+		/* See comment at the declaration of n.  Note: resplen = n;  */
+		DIAG_PUSH_NEEDS_COMMENT;
+		DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized");
 		/* Mask the AD bit in both responses unless it is
 		   marked trusted.  */
 		if (resplen > HFIXEDSZ)
@@ -543,6 +546,7 @@  __res_context_send (struct resolv_context *ctx,
 		    else
 		      mask_ad_bit (ctx, ans);
 		  }
+		DIAG_POP_NEEDS_COMMENT;
 		if (resplen2 != NULL && *resplen2 > HFIXEDSZ)
 		  mask_ad_bit (ctx, *ansp2);