public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
@ 2008-09-09 21:07 Steven Noonan
  2008-09-10  6:55 ` Ingo Molnar
  2008-09-10 21:09 ` Bartlomiej Zolnierkiewicz
  0 siblings, 2 replies; 8+ messages in thread
From: Steven Noonan @ 2008-09-09 21:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, Steven Noonan

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
  2008-09-09 21:07 [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc' Steven Noonan
@ 2008-09-10  6:55 ` Ingo Molnar
  2008-09-10 21:09 ` Bartlomiej Zolnierkiewicz
  1 sibling, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2008-09-10  6:55 UTC (permalink / raw)
  To: Steven Noonan; +Cc: linux-kernel, Bartlomiej Zolnierkiewicz

[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]


* Steven Noonan <steven@uplinklabs.net> wrote:

> 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(-)

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

[-- Attachment #2: git-authors-email --]
[-- Type: text/plain, Size: 151 bytes --]


#[ $# -lt "1" ] && { echo 'usage: git authors <files...>'; exit -1; }

git log $@ | grep Author: | cut -d: -f2 | sort | uniq -c | sort -n | tail -5



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
  2008-09-09 21:07 [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc' Steven Noonan
  2008-09-10  6:55 ` Ingo Molnar
@ 2008-09-10 21:09 ` Bartlomiej Zolnierkiewicz
  2008-09-10 21:19   ` Steven Noonan
  1 sibling, 1 reply; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-10 21:09 UTC (permalink / raw)
  To: Steven Noonan; +Cc: linux-kernel, mingo


Hi,

On Tuesday 09 September 2008, Steven Noonan wrote:
> 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]);

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
  2008-09-10 21:09 ` Bartlomiej Zolnierkiewicz
@ 2008-09-10 21:19   ` Steven Noonan
  2008-09-10 22:40     ` Elias Oltmanns
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Noonan @ 2008-09-10 21:19 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, mingo

On Wed, Sep 10, 2008 at 2:09 PM, Bartlomiej Zolnierkiewicz
<bzolnier@gmail.com> wrote:
>
> I recall seeing identical patch before:
>
>        http://article.gmane.org/gmane.linux.ide/33107
>
> Does the existing code really results in gcc warning?
>
>

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

- Steven

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
  2008-09-10 21:19   ` Steven Noonan
@ 2008-09-10 22:40     ` Elias Oltmanns
  2008-09-10 22:44       ` Steven Noonan
  0 siblings, 1 reply; 8+ messages in thread
From: Elias Oltmanns @ 2008-09-10 22:40 UTC (permalink / raw)
  To: Steven Noonan; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel, mingo

"Steven Noonan" <steven@uplinklabs.net> wrote:
> On Wed, Sep 10, 2008 at 2:09 PM, Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com> wrote:
>>
>
>> I recall seeing identical patch before:
>>
>>        http://article.gmane.org/gmane.linux.ide/33107
>>
>> Does the existing code really results in gcc warning?
>>
>>
>
> Yes, because GCC thinks it's possible that the for loop has zero
> iterations (and hence, 'rc' is never touched).

What about changing the declaration to

	int i, uninitialized_var(rc);

then?

Regards,

Elias

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
  2008-09-10 22:40     ` Elias Oltmanns
@ 2008-09-10 22:44       ` Steven Noonan
  2008-09-27 15:40         ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Noonan @ 2008-09-10 22:44 UTC (permalink / raw)
  To: Elias Oltmanns; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel, mingo

On Wed, Sep 10, 2008 at 3:40 PM, Elias Oltmanns <eo@nebensachen.de> wrote:
>
> What about changing the declaration to
>
>        int i, uninitialized_var(rc);
>
> then?
>

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

- Steven

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
  2008-09-10 22:44       ` Steven Noonan
@ 2008-09-27 15:40         ` Bartlomiej Zolnierkiewicz
  2008-10-05 16:14           ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-27 15:40 UTC (permalink / raw)
  To: Steven Noonan; +Cc: Elias Oltmanns, linux-kernel, mingo

On Thursday 11 September 2008, Steven Noonan wrote:
> On Wed, Sep 10, 2008 at 3:40 PM, Elias Oltmanns <eo@nebensachen.de> wrote:
> >
> > What about changing the declaration to
> >
> >        int i, uninitialized_var(rc);
> >
> > then?
> >
> 
> That's probably a -much- better idea. I'm an utter newbie to kernel
> development, so I wasn't aware of that feature.

Did I miss the final patch version?

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

Thanks,
Bart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc'
  2008-09-27 15:40         ` Bartlomiej Zolnierkiewicz
@ 2008-10-05 16:14           ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-10-05 16:14 UTC (permalink / raw)
  To: Steven Noonan; +Cc: Elias Oltmanns, linux-kernel, mingo

On Saturday 27 September 2008, Bartlomiej Zolnierkiewicz wrote:
> On Thursday 11 September 2008, Steven Noonan wrote:
> > On Wed, Sep 10, 2008 at 3:40 PM, Elias Oltmanns <eo@nebensachen.de> wrote:
> > >
> > > What about changing the declaration to
> > >
> > >        int i, uninitialized_var(rc);
> > >
> > > then?
> > >
> > 
> > That's probably a -much- better idea. I'm an utter newbie to kernel
> > development, so I wasn't aware of that feature.
> 
> Did I miss the final patch version?
> 
> [ Could you please re-send and/or re-cast it? ]

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]);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-10-05 16:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-09 21:07 [PATCH] drivers/ide/ide-probe.c: uninitialized variable 'rc' Steven Noonan
2008-09-10  6:55 ` Ingo Molnar
2008-09-10 21:09 ` Bartlomiej Zolnierkiewicz
2008-09-10 21:19   ` Steven Noonan
2008-09-10 22:40     ` Elias Oltmanns
2008-09-10 22:44       ` Steven Noonan
2008-09-27 15:40         ` Bartlomiej Zolnierkiewicz
2008-10-05 16:14           ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox