From patchwork Thu Dec 11 11:39:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 4175 Received: (qmail 18210 invoked by alias); 11 Dec 2014 11:39:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 18199 invoked by uid 89); 11 Dec 2014 11:39:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: plane.gmane.org To: libc-alpha@sourceware.org From: Stefan Liebler Subject: Re: [PATCH] powerpc: Fix unitialized variable Date: Thu, 11 Dec 2014 12:39:16 +0100 Lines: 102 Message-ID: References: <54889AAC.3060404@linux.vnet.ibm.com> <5488DA58.9010505@linux.vnet.ibm.com> Mime-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <5488DA58.9010505@linux.vnet.ibm.com> Hi Adhemerval, i get the warning: ‘resplen’ may be used uninitialized in this function [-Wmaybe-uninitialized] on s390, too. This patch disables Wmaybe-uninitialized warning on s390x with gcc 4.8, 4.9 and gcc from today, but not on power. Please test if it fixes your warnings too. Bye Stefan --- 2014-12-11 Stefan Liebler resolv/res_send.c (send_vc): Disable warning resplen may be used uninitialized. On 12/11/2014 12:42 AM, Adhemerval Zanella wrote: > On 10-12-2014 19:22, Joseph Myers wrote: >> On Wed, 10 Dec 2014, Adhemerval Zanella wrote: >> >>> The 'resolv/res_send.c' build with _STRING_ARCH_unaligned not defined >>> may utilize the local resplen uninitialized. This patch sets it to 0. >> Do you have an actual path through the function that can result in it >> being used uninitialized, and where a value of 0 is correct? > > I do not, I used as default just to avoid the warning. > >> >> My understanding, as described in >> , was that >> this is a false positive warning - the variable is never actually used >> uninitialized, but determining that requires considering the values other >> variables can have on the paths leading to resplen being used. And since >> we don't want to add initializations (to installed code as opposed to >> testcases) that actually require code to be generated simply in order to >> avoid warnings, that may indicate disabling -Wmaybe-uninitialized around >> the code that generates the warning. >> > I understand the idea of avoid such warning, I will the compiler directives. > > > diff --git a/resolv/res_send.c b/resolv/res_send.c index af42b8a..9c2418b 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 #include #include +#include #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´s 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; 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; #else int aligned_resplen = ((resplen + __alignof__ (HEADER) - 1)