From patchwork Thu Jul 10 05:06:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1993 Received: (qmail 21851 invoked by alias); 10 Jul 2014 05:07:10 -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 21568 invoked by uid 89); 10 Jul 2014 05:07:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Thu, 10 Jul 2014 10:36:53 +0530 From: Siddhesh Poyarekar To: Roland McGrath Cc: libc-alpha@sourceware.org Subject: Re: Fix -Wmaybe-uninitialized warning in xdr.c Message-ID: <20140710050653.GY609@spoyarek.pnq.redhat.com> References: <20140708175919.GL609@spoyarek.pnq.redhat.com> <20140709193945.D12112C39A9@topped-with-meat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140709193945.D12112C39A9@topped-with-meat.com> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) On Wed, Jul 09, 2014 at 12:39:45PM -0700, Roland McGrath wrote: > Nowadays, we probably want to use a balancing test of the performance vs > the ease-of-maintenance improvement of eliminating warnings. It seems > almost certain that we don't care about the cost of the dead store in > xdr_string. But IMHO it should always be an explicit decision to trade off > after careful consideration of the particular case. It should never be a > default-OK to pessimize the code to work around the compiler's lack of > intelligence. Certainly any change made for that reason should have > comments saying that the initialization is not actually desirable but was > added to silence a compiler warning. OK, I'll keep this in mind. I've also added a comment like you suggested. Thanks, Siddhesh commit d69b7f5ac02989ce3d8577eed86da3e0c8af6c1c Author: Siddhesh Poyarekar Date: Thu Jul 10 10:32:29 2014 +0530 Add comment about SIZE initialization in xdr.c diff --git a/ChangeLog b/ChangeLog index dfd393b..a8aa74b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-07-10 Siddhesh Poyarekar + + * sunrpc/xdr.c (xdr_string): Add comment about SIZE + initialization. + 2014-07-09 David S. Miller * sysdeps/sparc/fpu/libm-test-ulps: Update. diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c index 129abd8..fade667 100644 --- a/sunrpc/xdr.c +++ b/sunrpc/xdr.c @@ -739,6 +739,8 @@ xdr_string (xdrs, cpp, maxsize) u_int maxsize; { char *sp = *cpp; /* sp is the actual string pointer */ + /* Initialize to silence the compiler. It is not really needed because SIZE + never actually gets used without being initialized. */ u_int size = 0; u_int nodesize;