Bug 149889 - local variable used before set
Summary: local variable used before set
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: netdiag
Version: 3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Dams
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-02-28 17:24 UTC by David Binderman
Modified: 2007-11-30 22:11 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 2005-07-24 01:03:01 UTC


Attachments (Terms of Use)

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.



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