From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756308AbcKVRp3 (ORCPT ); Tue, 22 Nov 2016 12:45:29 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:36442 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288AbcKVRp1 (ORCPT ); Tue, 22 Nov 2016 12:45:27 -0500 Subject: Re: [PATCH 2/2] PCI: iproc: avoid maybe-uninitialized warning To: Arnd Bergmann , Bjorn Helgaas References: <20161122141844.1655574-1-arnd@arndb.de> <20161122141844.1655574-2-arnd@arndb.de> Cc: Ray Jui , Scott Branden , Jon Mason , bcm-kernel-feedback-list@broadcom.com, Oza Oza , "Dmitry V. Krivenok" , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org From: Ray Jui Message-ID: <31c4c52b-3de5-2277-7a44-2a4231531074@broadcom.com> Date: Tue, 22 Nov 2016 09:45:24 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Thunderbird/50.0 MIME-Version: 1.0 In-Reply-To: <20161122141844.1655574-2-arnd@arndb.de> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, On 11/22/2016 6:17 AM, Arnd Bergmann wrote: > gcc notices that calling iproc_pcie_setup_ib with ib->nr_regions==0 > would result in an uninitialized return value: > > drivers/pci/host/pcie-iproc.c: In function 'iproc_pcie_setup_ib': > drivers/pci/host/pcie-iproc.c:894:6: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > This can't really happen, but the correct behavior of the function > is probably to return -EINVAL if it ever did. > > Fixes: 4213e15c364e ("PCI: iproc: Make outbound mapping code more generic") > Signed-off-by: Arnd Bergmann > --- > drivers/pci/host/pcie-iproc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c > index 857ff5198317..0359569c8d78 100644 > --- a/drivers/pci/host/pcie-iproc.c > +++ b/drivers/pci/host/pcie-iproc.c > @@ -936,6 +936,7 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie, > > } > } > + ret = -EINVAL; > err_ib: > dev_err(dev, "unable to configure inbound mapping\n"); > dev_err(dev, "axi %pap, pci %pap, res size %pap\n", > This change is good, but in my opinion, a further improvement for clarity would be to initialize 'ret' to -EINVAL in the beginning of this function when 'ret' is declared. What do you think? Thanks, Ray