Bug 149889

Summary: local variable used before set
Product: [Fedora] Fedora Reporter: David Binderman <dcb314>
Component: netdiagAssignee: Dams <anvil>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 3   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-07-24 01:03:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Binderman 2005-02-28 17:24:43 UTC
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);
                        do
                                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:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Michael Schwendt 2005-07-23 19:05:23 UTC
"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 22:12:06 UTC
>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 23:35:56 UTC
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.