From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shinya Kuribayashi Date: Wed, 06 Jun 2007 11:18:12 +0900 Subject: [U-Boot-Users] [PATCH] PCI_READ_VIA_DWORD_OP: initialize val parameter on fail In-Reply-To: <46660525.3000708@necel.com> References: <20070605160404.AA899353A97@atlas.denx.de> <46660525.3000708@necel.com> Message-ID: <46661964.1080708@necel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de >> I know that this is not your invention, and you just copy existing >> code, but I think injecting C statements like this through macro >> arguments is bad style and should be avoided. >> >> I have to admit that I don't get wht you need all this "error_code" >> trickery instead of simpley writing >> >> *val = -1; >> >> >> Can you please change your patch like that, Many users of PCI config read routines tend to ignore the function ret value, and are only concerned about the contents of *val. Based on this, pci_hose_read_config_{byte,word}_via_dword should initialize the *val on dword read error. Without this fix, for example, we'll go on scanning bus with vendor or header_type uninitialized. This brings many unnecessary config trials. Signed-off-by: Shinya Kuribayashi --- drivers/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Index: b/drivers/pci.c =================================================================== --- a/drivers/pci.c +++ b/drivers/pci.c @@ -81,8 +81,10 @@ int pci_hose_read_config_##size##_via_dw { \ u32 val32; \ \ - if (pci_hose_read_config_dword(hose, dev, offset & 0xfc, &val32) < 0)\ + if (pci_hose_read_config_dword(hose, dev, offset & 0xfc, &val32) < 0) { \ + *val = -1; \ return -1; \ + } \ \ *val = (val32 >> ((offset & (int)off_mask) * 8)); \ \