[PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'

Previous thread: 2.6.26.5-rt8 by Steven Rostedt on Tuesday, September 9, 2008 - 8:48 pm. (1 message)

Next thread: [PATCH] x86: rename discontig_32.c to numa_32.c by Yinghai Lu on Tuesday, September 9, 2008 - 11:34 pm. (2 messages)
From: Steven Noonan
Date: Tuesday, September 9, 2008 - 2:07 pm

Fixed the warning by initializing 'rc' to zero.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
---
 drivers/ide/ide-probe.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 994e410..e53c645 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1492,7 +1492,7 @@ static struct device_attribute *ide_port_attrs[] = {
 
 static int ide_sysfs_register_port(ide_hwif_t *hwif)
 {
-	int i, rc;
+	int i, rc = 0;
 
 	for (i = 0; ide_port_attrs[i]; i++) {
 		rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
-- 
1.6.0.1

--

From: Ingo Molnar
Date: Tuesday, September 9, 2008 - 11:55 pm

i've Cc:-ed Bartlomiej, who maintains drivers/ide/ide-probe.c. Your 
fix/cleanup looks fine to me.

About the "whom to Cc:" question. Sadly, the MAINTAINERS file is 
non-obvious to parse to newbies: there's no clear mapping from file to 
maintainer. (it's rather useless even to oldbies.)

The method i use to determine whom to Cc: if i change something in a 
file is this ~/bin/git-authors script:

 #!/bin/bash
 git log $@ | grep Author: | cut -d: -f2 | sort | uniq -c | sort -n | tail -5

(also attached)

for drivers/ide/ide-probe.c, it gives:

 earth4:~/tip> git-authors-email drivers/ide/ide-probe.c
       2  Christoph Lameter <christoph@lameter.com>
       2  Greg Kroah-Hartman <gregkh@suse.de>
       3  Jens Axboe <jens.axboe@oracle.com>
       4  Jens Axboe <axboe@suse.de>
     135  Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

if there output of git-authors-email is too flat and you are unsure 
about whom to Cc:, take a look at git-log drivers/ide/ide-probe.c output 
and chose the people who do material changes to a file (not drive-by 
changes).

	Ingo
From: Bartlomiej Zolnierkiewicz
Date: Wednesday, September 10, 2008 - 2:09 pm

Hi,


I recall seeing identical patch before:

	http://article.gmane.org/gmane.linux.ide/33107

Does the existing code really results in gcc warning?

If so we may apply it just to shut-up the broken gcc version...

Thanks,
Bart
--

From: Steven Noonan
Date: Wednesday, September 10, 2008 - 2:19 pm

On Wed, Sep 10, 2008 at 2:09 PM, Bartlomiej Zolnierkiewicz

Yes, because GCC thinks it's possible that the for loop has zero
iterations (and hence, 'rc' is never touched).

- Steven
--

From: Elias Oltmanns
Date: Wednesday, September 10, 2008 - 3:40 pm

What about changing the declaration to

	int i, uninitialized_var(rc);

then?

Regards,

Elias
--

From: Steven Noonan
Date: Wednesday, September 10, 2008 - 3:44 pm

That's probably a -much- better idea. I'm an utter newbie to kernel
development, so I wasn't aware of that feature.

- Steven
--

From: Bartlomiej Zolnierkiewicz
Date: Saturday, September 27, 2008 - 8:40 am

Did I miss the final patch version?

[ Could you please re-send and/or re-cast it? ]

Thanks,
Bart
--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, October 5, 2008 - 9:14 am

Oh, well...

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: workaround for bogus gcc warning in ide_sysfs_register_port()

Reported-by: "Steven Noonan" <steven@uplinklabs.net>
Suggested-by: "Elias Oltmanns" <eo@nebensachen.de>
Cc: mingo@elte.hu
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-probe.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1492,7 +1492,7 @@ static struct device_attribute *ide_port
 
 static int ide_sysfs_register_port(ide_hwif_t *hwif)
 {
-	int i, rc;
+	int i, uninitialized_var(rc);
 
 	for (i = 0; ide_port_attrs[i]; i++) {
 		rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
--

Previous thread: 2.6.26.5-rt8 by Steven Rostedt on Tuesday, September 9, 2008 - 8:48 pm. (1 message)

Next thread: [PATCH] x86: rename discontig_32.c to numa_32.c by Yinghai Lu on Tuesday, September 9, 2008 - 11:34 pm. (2 messages)