Bug 155947

Summary: netdiag-20010114-397: local variable used before set
Product: [openSUSE] SUSE LINUX 10.0 Reporter: David Binderman <dcb314>
Component: BasesystemAssignee: Marcus Rückert <mrueckert>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: SuSE Linux 10.1   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description David Binderman 2006-03-07 22:25:44 UTC
I just tried to compile package netdiag-20010114-397 with the Intel C compiler.

It said

tulip-diag.c(891): warning #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;

I agree with the compiler.  Suggest initialise local variable "sum" 
before first use.
Comment 1 Marcus Rückert 2006-03-16 13:28:58 UTC
the sum variable is only used inside this loop.
gcc doesnt warn about it as it eliminates this variable in the optimizer.
the gcc warnings for uninitialized variables are emitted after this optimization step.

the real fix might be removing the declaration of sum and the one line where it is used. but i would ask upstream about this suggestion first. i dont think it is worth fixing a "non" bug.