Bug 135586

Summary: xglx-050705-5: 2 * local variable used before set
Product: [openSUSE] SUSE LINUX 10.0 Reporter: David Binderman <dcb314>
Component: BasesystemAssignee: Matthias Hopf <mhopf>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P5 - None    
Version: Final   
Target Milestone: ---   
Hardware: All   
OS: SuSE Linux 10.0   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description David Binderman 2005-11-26 12:08:28 UTC
I just tried to compile package xglx-050705-5 with a GNU C compiler

It said

1.

fbbits.h:829: warning: "bits" is used uninitialized in this function

The source code is

    bits += bitsStride * yoff + xoff * MUL;

I have read the source code, and I agree with the compiler. 
Suggest initialise local variable "bits" before first use.

2.

../../GL/mesa/src/mesa/shader/slang/slang_assemble_constructor.c:267: warning: "master_rows" is used uninitialized in this function

The source code is

        for (i = 0; i < master_rows; i++)

I have read the source code, and I agree with the compiler. 
Suggest initialise local variable "master_rows" before first use.
Comment 1 Matthias Hopf 2005-11-29 15:29:47 UTC
(In reply to comment #0)
> fbbits.h:829: warning: "bits" is used uninitialized in this function
> I have read the source code, and I agree with the compiler. 
> Suggest initialise local variable "bits" before first use.

Actually, bits is never used before initialized. So this unitialized variable had no bad side effect. I nuked that line, thanks!

Note that this will not show up in the xglx package any more, as it is superseeded by the xgl package that will be shipped beginning with SL 10.1.
The code base has changed pretty much as well...

> ../../GL/mesa/src/mesa/shader/slang/slang_assemble_constructor.c:267: warning:
> "master_rows" is used uninitialized in this function

I would agree with *may* be used unitialized, but not with *is*.
However, master_spec->type has to be one of the switch cases, the default section could even have an abort() AFAICS.

> I have read the source code, and I agree with the compiler. 

I don't. It typically is initialized. One should code safe, though.
As this is still present in the current Mesa sources, this could be filed as a bug for upstream Mesa development.

However, the function does not seem to do the right thing anyway (/* XXX: wrong */ in the function header). I doubt it is of any use to do something here in the current state the shader assember is in.