Skip to contentSkip to conversation

silence gcc warning about possibly uninitialized use of variable in scsi_scan

PATCH James Bottomley 2 participants 6 messages Feb 26, 2006 1 message not in the archive SCSI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · Jesper Juhl

Gcc can't see that 'result' will always be initialized inside the for loop
and thus it warns
drivers/scsi/scsi_scan.c:445: warning: 'result' might be used uninitialized in this function
This patch silences the warning by initializing 'result' to zero.

Really, this is a gcc bug. My version of the compiler:

gcc version 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)

Doesn't give this warning. And, since the loop has fixed parameters, gcc should see not only that it's always executed, but that it could be unrolled.

Which version is causing the problem?

James

#2 lore raw
Quoted 8 lines · James Bottomley
Quoted 4 lines · Jesper Juhl

Gcc can't see that 'result' will always be initialized inside the for loop
and thus it warns
drivers/scsi/scsi_scan.c:445: warning: 'result' might be used uninitialized in this function
This patch silences the warning by initializing 'result' to zero.

Really, this is a gcc bug. My version of the compiler:

Quoted 8 lines

gcc version 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)

Doesn't give this warning. And, since the loop has fixed parameters, gcc should see not only that it's always executed, but that it could be unrolled.

Which version is causing the problem?

2.6.16-rc4-mm2 build with gcc 3.4.5

and I agree that gcc really should be noticing, but in fact it doesn't. It's no big deal, I just thought we might want to shut gcc up and give people one less warning to worry about.

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

#3 lore raw
Quoted 9 lines · Jesper Juhl
Quoted 8 lines

gcc version 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)

Doesn't give this warning. And, since the loop has fixed parameters, gcc should see not only that it's always executed, but that it could be unrolled.

Which version is causing the problem?

2.6.16-rc4-mm2 build with gcc 3.4.5

I also tried with

gcc version 3.3.5 (Debian 1:3.3.5-13)

which likewise fails to give this warning, so I really think this is a bug in your particular version of gcc.

James

Quoted 12 lines

and I agree that gcc really should be noticing, but in fact it doesn't. It's no big deal, I just thought we might want to shut gcc up and give people one less warning to worry about.

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 9 lines · James Bottomley
Quoted 8 lines · Jesper Juhl
Quoted 8 lines

gcc version 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)

Doesn't give this warning. And, since the loop has fixed parameters, gcc should see not only that it's always executed, but that it could be unrolled.

Which version is causing the problem?

Quoted 9 lines
Quoted 1 line

2.6.16-rc4-mm2 build with gcc 3.4.5

I also tried with

gcc version 3.3.5 (Debian 1:3.3.5-13)

which likewise fails to give this warning, so I really think this is a bug in your particular version of gcc.

Hmm, it's quite reproducible and the gcc 3.4.5 I have here is not patched by the distribution (Slackware). If you want I can send you the .config that results in the warning..

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

#5 lore raw
Quoted 3 lines · Jesper Juhl

Hmm, it's quite reproducible and the gcc 3.4.5 I have here is not patched by the distribution (Slackware). If you want I can send you the .config that results in the warning..

I really don't think it's a config issue. scsi_probe_lun() is always compiled in if CONFIG_SCSI is set. I think you have a compiler problem.

James

#6 lore raw
Quoted 8 lines · James Bottomley
Quoted 3 lines · Jesper Juhl

Hmm, it's quite reproducible and the gcc 3.4.5 I have here is not patched by the distribution (Slackware). If you want I can send you the .config that results in the warning..

I really don't think it's a config issue. scsi_probe_lun() is always compiled in if CONFIG_SCSI is set. I think you have a compiler problem.

I must admit I think the compiler is OK.
I have two different boxes with gcc 3.4.5 and they both give the same warning (not to mention that that gcc builds everything I've thrown at it correctly).
But nevermind, it's just a silly little warning - just leave it be.

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html