Issue 49387

Summary: sch: warning: uninitialized variable is used
Product: General Reporter: pmladek <pmladek>
Component: chartAssignee: bjoern.milcke
Status: CLOSED FIXED QA Contact: issues@graphics <issues>
Severity: Trivial    
Priority: P3 CC: issues
Version: 3.3.0 or older (OOo)   
Target Milestone: ---   
Hardware: PC   
OS: Linux, all   
Issue Type: PATCH Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
This patch initializes the problematic variable. none

Description pmladek 2005-05-17 13:55:46 UTC
The new gcc-4.0-pre has a better detection of problems with uninitialized
variables and prints the new "warning: FOO is used uninitialized". We are going
through this warnings because there is a higher chance that the code is really
broken.

The following problems were found in the module sch:

/usr/src/packages/BUILD/ooo-build-1.9.100/build/src680-m100/sch/source/ui/dlg/tplabel.cxx:
In member function ‘virtual BOOL SchAxisLabelTabPage::FillItemSet(SfxItemSet&)’:
/usr/src/packages/BUILD/ooo-build-1.9.100/build/src680-m100/sch/source/ui/dlg/tplabel.cxx:174:
warning: ‘eOrient’ is used uninitialized in this function

The variable ‘eOrient’ is used this way:

BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs )
{
        SvxChartTextOrient eOrient;
...
    BOOL bStacked = aOrientHlp.GetStackedState() == STATE_CHECK;
    if( bStacked != m_bInitialStacking )
    {
        if( bStacked )
        {
            eOrient = CHTXTORIENT_STACKED;
            rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, 0 ) );
        }
    }
        
    if( eOrient != CHTXTORIENT_STACKED )
        {
...

It is set to CHTXTORIENT_STACKED only in some special cases but it is checked in
all cases. It might look that there is a small chance that the variable is set
to CHTXTORIENT_STACKED by default. I think that the chance is not so small
because the method could be called more times and the value CHTXTORIENT_STACKED
could be saved in the memory stack from the previous call.

I'll attach a patch that initializes the variable.
Comment 1 pmladek 2005-05-17 13:57:04 UTC
Created attachment 26233 [details]
This patch initializes the problematic variable.
Comment 2 kla 2005-05-18 15:19:10 UTC
->BM: One for you.
Comment 3 bjoern.milcke 2005-05-25 10:16:28 UTC
I applied the patch to get rid of the warning. Applying the item unconditionally
(some lines below) is also a bad idea, but as sch will hopefully be deprecated
soon and things are sometimes more interwoven than one thinks, I will keep it
the way it is.

The orient item should be obsolete and therefore not used in the code elsewhere,
so there should be no difference in the behaviour of the chart (and if it will
be it will be a good one, as uninitialized values may have probably sporadic but
bad effects). However, again, I keep it the way it is to avoid introducing side
effect issues.
Comment 4 christof.pintaske 2005-05-25 13:46:17 UTC
Retargeted to Office Later, due to lack of resources we have to concentrate on
the most relevant issues for the next micro update.
Comment 5 christof.pintaske 2005-05-25 13:47:34 UTC
ooops, forget about the stuff above ...
Comment 6 bjoern.milcke 2005-08-11 15:05:34 UTC
Patch is present in the dr37 build.
Comment 7 bjoern.milcke 2005-08-18 08:44:27 UTC
Issue type changed
Comment 8 bjoern.milcke 2005-10-07 10:38:49 UTC
Ok in Master SRC680.m132