Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 155330 - local variable used before set
Summary: local variable used before set
Alias: None
Product: Fedora
Classification: Fedora
Component: kdegraphics
Version: rawhide
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Ngo Than
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2005-04-19 08:45 UTC by David Binderman
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2005-07-27 15:02:08 UTC

Attachments (Terms of Use)

Description David Binderman 2005-04-19 08:45:15 UTC
Description of problem:

I just tried to compile kdegraphics-3.4.0-2 from Redhat
Fedora Core development tree

The compiler said

kpcursorlightcross.cpp:75: warning: 'colorValue' is used uninitialized in this

The source code is

    if (colorValue)

I agree with the compiler. Suggest initialise colorValue before first use.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:

Comment 1 Ngo Than 2005-07-27 15:02:08 UTC
i have taken a look here. The code looks sane for me!

    int colorValue, maskValue;

    switch (pv)
    case White:
        colorValue = ColorWhite;
        maskValue = MaskOpaque;

    case Black:
        colorValue = ColorBlack;
        maskValue = MaskOpaque;

    case Transparent:
        colorValue = ColorWhite;
        maskValue = MaskTransparent;

    if (colorValue)

Comment 2 David Binderman 2005-07-27 22:24:13 UTC
>The code looks sane for me!

I'm guessing why you think that.

Maybe you think that there is default initialisation of local variables
to zero in C or maybe that pv can take only one of three values ?

In either case, I still strongly recommend initialisation of colorValue
*before* the switch statement is evaluated. 

switch statements have a nasty habit of having none of the cases executed.

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