Red Hat Bugzilla – Bug 149889
local variable used before set
Last modified: 2007-11-30 17:11:00 EST
Description of problem:
I just tried to compile package netdiag-2.4-4 from
Redhat Fedora Extras development tree.
The compiler said
tulip-diag.c(891): remark #592: variable "sum" is used before its
value is set
The source code is
outl(0x600 | i, ioaddr + 0x98);
value = inl(ioaddr + CSR9);
while (value < 0 && --boguscnt > 0);
((u_int16_t *)eeprom_contents)[i] = value;
sum += value & 0xffff;
Suggest init local variable "sum" before first use.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
"sum" is a local/temporary variable and is only assigned to. It's not read
later. Could be for debugging purposes, whatever. Not a bug, no threat or
side-effects or anything like that.
>is only assigned to
So what happens if someone writes code which assumes
that local variable "sum" has something of value in it ?
Suggest either the local variable is useless, and so it can
be removed, or that it does something useful and so it should
be initialised to something sensible.
You can't have your cake and eat it, surely ?
Fedora Extras is the wrong place where to "suggest" such code modifications. It
would imply that we apply a patch, which doesn't increase the value of the built
software and which might need to be revisited and updated for future version
upgrades for no benefit. If upstream developers chose to insert that line of
code in this place, that is their decision. Please seek contact with the
upstream project if you want to discuss the usefulness of that code.