Apache OpenOffice (AOO) Bugzilla – Issue 49387
sch: warning: uninitialized variable is used
Last modified: 2013-02-24 21:22:31 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.
Created attachment 26233 [details] This patch initializes the problematic variable.
->BM: One for you.
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.
Retargeted to Office Later, due to lack of resources we have to concentrate on the most relevant issues for the next micro update.
ooops, forget about the stuff above ...
Patch is present in the dr37 build.
Issue type changed
Ok in Master SRC680.m132