public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Jianjun Kong <jianjun@zeuux.org>
Cc: mingo@redhat.com,
	Linux-Kernel-Mailing-List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] x86: fix warning of uninitialized variable
Date: Thu, 4 Dec 2008 11:10:23 +0100	[thread overview]
Message-ID: <20081204101023.GA18708@elte.hu> (raw)
In-Reply-To: <20081204010013.GA17445@ubuntu>


* Jianjun Kong <jianjun@zeuux.org> wrote:

> fix warning of uninitialized 'base' in arch/x86/kernel/scx200_32.c
> 
> arch/x86/kernel/scx200_32.c: In function ‘scx200_probe’:
> arch/x86/kernel/scx200_32.c:82: warning: ‘base’ may be used
> uninitialized in this function
> 
> Signed-off-by: Jianjun Kong <jianjun@zeuux.org>
> ---
>  arch/x86/kernel/scx200_32.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

this patch is wrong, and your analysis-free commit log is wrong as well!

i fixed this a few weeks ago, and GCC pinpointed a _real_ bug - which you 
hacked around instead of fixing. See the real fix below.

	Ingo

---------------------->
>From 6f9fecb3d70400c5f99c1a1d09ffcce84483f611 Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Sat, 18 Oct 2008 17:37:39 +0200
Subject: [PATCH] fix warning in arch/x86/kernel/scx200_32.c
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

fix this warning:

  arch/x86/kernel/scx200_32.c: In function ‘scx200_probe’:
  arch/x86/kernel/scx200_32.c:82: warning: ‘base’ may be used uninitialized in this function

gcc is right: pci_read_config_dword() can fail, and this code did not
handle it.

Add proper error handling.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/scx200_32.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/scx200_32.c b/arch/x86/kernel/scx200_32.c
index 7e004ac..1b6e3d1 100644
--- a/arch/x86/kernel/scx200_32.c
+++ b/arch/x86/kernel/scx200_32.c
@@ -78,8 +78,10 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_
 		if (scx200_cb_probe(SCx200_CB_BASE_FIXED)) {
 			scx200_cb_base = SCx200_CB_BASE_FIXED;
 		} else {
-			pci_read_config_dword(pdev, SCx200_CBA_SCRATCH, &base);
-			if (scx200_cb_probe(base)) {
+			int err;
+
+			err = pci_read_config_dword(pdev, SCx200_CBA_SCRATCH, &base);
+			if (!err && scx200_cb_probe(base)) {
 				scx200_cb_base = base;
 			} else {
 				printk(KERN_WARNING NAME ": Configuration Block not found\n");


  reply	other threads:[~2008-12-04 10:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-04  1:00 [PATCH 1/3] x86: fix warning of uninitialized variable Jianjun Kong
2008-12-04 10:10 ` Ingo Molnar [this message]
2008-12-04 10:16   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081204101023.GA18708@elte.hu \
    --to=mingo@elte.hu \
    --cc=jianjun@zeuux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox