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
--
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
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 --
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 --
What about changing the declaration to int i, uninitialized_var(rc); then? Regards, Elias --
That's probably a -much- better idea. I'm an utter newbie to kernel development, so I wasn't aware of that feature. - Steven --
Did I miss the final patch version? [ Could you please re-send and/or re-cast it? ] Thanks, Bart --
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]); --
