This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] powerpc: Fix unitialized variable
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Thu, 11 Dec 2014 10:47:25 -0200
- Subject: Re: [PATCH] powerpc: Fix unitialized variable
- Authentication-results: sourceware.org; auth=none
- References: <54889AAC dot 3060404 at linux dot vnet dot ibm dot com> <alpine dot DEB dot 2 dot 10 dot 1412102119230 dot 26602 at digraph dot polyomino dot org dot uk> <5488DA58 dot 9010505 at linux dot vnet dot ibm dot com> <m6bvp4$tus$1 at ger dot gmane dot org> <mvmsigmpfku dot fsf at hawking dot suse dot de> <m6c0u2$o15$1 at ger dot gmane dot org> <54898F5B dot 2000904 at linux dot vnet dot ibm dot com>
On 11-12-2014 10:34, Adhemerval Zanella wrote:
> On 11-12-2014 09:58, Stefan Liebler wrote:
>> On 12/11/2014 12:54 PM, Andreas Schwab wrote:
>>> Stefan Liebler <stli@linux.vnet.ibm.com> writes:
>>>
>>>> + /* ThereÂs the following warning on S390:
>>> Please avoid non-ascii.
>>>
>>> Andreas.
>>>
>> Oh. Ok. Here is it without Â.
> I was about to send a similar patch.
>
>> ---
>> 2014-12-11 Stefan Liebler <stli@linux.vnet.ibm.com>
>>
>> resolv/res_send.c (send_vc): Disable warning resplen may
>> be used uninitialized.
>>
>> res_send_11122014
>>
>>
>> diff --git a/resolv/res_send.c b/resolv/res_send.c
>> index af42b8a..22b322c 100644
>> --- a/resolv/res_send.c
>> +++ b/resolv/res_send.c
>> @@ -96,6 +96,7 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi
>> #include <string.h>
>> #include <unistd.h>
>> #include <kernel-features.h>
>> +#include <libc-internal.h>
>>
>> #if PACKETSZ > 65536
>> #define MAXPACKET PACKETSZ
>> @@ -668,7 +669,17 @@ send_vc(res_state statp,
>> // int anssiz = *anssizp;
>> HEADER *anhp = (HEADER *) ans;
>> struct sockaddr_in6 *nsap = EXT(statp).nsaddrs[ns];
>> - int truncating, connreset, resplen, n;
>> + int truncating, connreset, n;
>> + /* There is the following warning on S390:
>> + 'resplen' may be used uninitialized in this function
>> + [-Wmaybe-uninitialized]
>> + This is a false positive according to:
>> + https://www.sourceware.org/ml/libc-alpha/2014-12/msg00323.html
>> + */
>> + DIAG_PUSH_NEEDS_COMMENT;
>> + DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
>> + int resplen;
>> + DIAG_POP_NEEDS_COMMENT;
> I would a comment saying it the compiler emits if architecture does not
> define '_STRING_ARCH_unaligned', instead of just for S390.
>
>> struct iovec iov[4];
>> u_short len;
>> u_short len2;
>> @@ -788,8 +799,11 @@ send_vc(res_state statp,
>> reply. We can try to use the rest
>> of the user-provided buffer. */
>> #if _STRING_ARCH_unaligned
>> + DIAG_PUSH_NEEDS_COMMENT;
>> + DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
>> *anssizp2 = orig_anssizp - resplen;
>> *ansp2 = *ansp + resplen;
>> + DIAG_POP_NEEDS_COMMENT;
> I am seeing the may be used uninitialized with GCC 4.7 and forward.
>
>> #else
>> int aligned_resplen
>> = ((resplen + __alignof__ (HEADER) - 1)
Here it is a more comprehensible patch that also suppress the warning for
powerpc (and possible other arches that do not define _STRING_ARCH_unaligned),
what do you think?
--
diff --git a/resolv/res_send.c b/resolv/res_send.c
index af42b8a..51ac05c 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -96,6 +96,7 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi
#include <string.h>
#include <unistd.h>
#include <kernel-features.h>
+#include <libc-internal.h>
#if PACKETSZ > 65536
#define MAXPACKET PACKETSZ
@@ -668,7 +669,17 @@ send_vc(res_state statp,
// int anssiz = *anssizp;
HEADER *anhp = (HEADER *) ans;
struct sockaddr_in6 *nsap = EXT(statp).nsaddrs[ns];
- int truncating, connreset, resplen, n;
+ int truncating, connreset, n;
+ /* There is the following warning on some architectures:
+ 'resplen' may be used uninitialized in this function
+ [-Wmaybe-uninitialized]
+ This is a false positive according to:
+ https://www.sourceware.org/ml/libc-alpha/2014-12/msg00323.html
+ */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.7, "-Wmaybe-uninitialized");
+ int resplen;
+ DIAG_POP_NEEDS_COMMENT;
struct iovec iov[4];
u_short len;
u_short len2;
@@ -787,6 +798,8 @@ send_vc(res_state statp,
/* No buffer allocated for the first
reply. We can try to use the rest
of the user-provided buffer. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.7, "-Wmaybe-uninitialized");
#if _STRING_ARCH_unaligned
*anssizp2 = orig_anssizp - resplen;
*ansp2 = *ansp + resplen;
@@ -797,6 +810,7 @@ send_vc(res_state statp,
*anssizp2 = orig_anssizp - aligned_resplen;
*ansp2 = *ansp + aligned_resplen;
#endif
+ DIAG_POP_NEEDS_COMMENT;
} else {
/* The first reply did not fit into the
user-provided buffer. Maybe the second