Bug 149889 - local variable used before set
local variable used before set
Product: Fedora
Classification: Fedora
Component: netdiag (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Dams
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2005-02-28 12:24 EST by David Binderman
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-07-23 21:03:01 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description David Binderman 2005-02-28 12:24:43 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

                        u_int16_t sum;
                        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):

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:
Comment 1 Michael Schwendt 2005-07-23 15:05:23 EDT
"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.
Comment 2 David Binderman 2005-07-23 18:12:06 EDT
>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 ?
Comment 3 Michael Schwendt 2005-07-23 19:35:56 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.