From patchwork Thu Dec 11 12:47:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 420092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 17D5914009B for ; Thu, 11 Dec 2014 23:47:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=AHJRHIixY3mnNPnaqzFR6uHsX0NWkUue2UglnEopgM9 gbzsHB+ejN9+3a0MUJiFpZiUin2lBRgDkQK8lM7uRrl28taoZ4CKW70kcdmQOibW mUEZd5FCwRuJRWCQHYDy197KkErN7VvPwfF0HdLRZzVxB4gjU/NwzYujo2fIdXXk = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=trUqZM25P6KihNyhl8bFOvhYy30=; b=le1SIRsqhnfqS83vw hLloSncJTRualgtOKzqySl6Tmb+ojnpC5VnQna8Zc8s9Udm30IDJxx4S+Q04VTIA 0sFHNqQoRKsIIJPAT9L44wxhCU5zuW9+sa5ElOg/Dqe/Jf//x42sjVzCQoG1/QXz rqYUjnoQfWrtnJ3hMm7/Hkym0Q= Received: (qmail 10804 invoked by alias); 11 Dec 2014 12:47:40 -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 10794 invoked by uid 89); 11 Dec 2014 12:47:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e24smtp01.br.ibm.com Message-ID: <5489925D.5010609@linux.vnet.ibm.com> Date: Thu, 11 Dec 2014 10:47:25 -0200 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: libc-alpha@sourceware.org Subject: Re: [PATCH] powerpc: Fix unitialized variable References: <54889AAC.3060404@linux.vnet.ibm.com> <5488DA58.9010505@linux.vnet.ibm.com> <54898F5B.2000904@linux.vnet.ibm.com> In-Reply-To: <54898F5B.2000904@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14121112-1524-0000-0000-0000014BC945 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 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 >> >> 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 >> #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 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 #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 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