Issue 49381 - sd: warning: uninitialized variable is used
Summary: sd: warning: uninitialized variable is used
Status: ACCEPTED
Alias: None
Product: Draw
Classification: Application
Component: code (show other issues)
Version: 680m100
Hardware: PC Linux, all
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-17 12:54 UTC by pmladek
Modified: 2017-05-20 10:47 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
This patch tries to fix the uninitialized variable. (730 bytes, patch)
2005-05-17 12:58 UTC, pmladek
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description pmladek 2005-05-17 12:54:55 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 sd:

/usr/src/packages/BUILD/ooo-build-1.9.100/build/src680-m100/sd/source/ui/view/ViewShellImplementation.cxx:
In member function ‘void
sd::ViewShell::Implementation::ProcessModifyPageSlot(SfxRequest&, SdPage*,
PageKind)’:
/usr/src/packages/BUILD/ooo-build-1.9.100/build/src680-m100/sd/source/ui/view/ViewShellImplementation.cxx:273:
warning: ‘aOldAutoLayout’ is used uninitialized in this function


The variable 'aOldAutoLayout' is used this way:

            if(bShowDialog)
            {
                sal_Bool bNameChanged(aNewName != aOldName);
                sal_Bool bLayoutChanged(aNewAutoLayout != aOldAutoLayout);
 
                if(bNameChanged && !bLayoutChanged)
                    bShowDialog = sal_False;
            }

but is is never initialized.

I think that it could be initialized this way:

aOldAutoLayout = pUndoPage->GetAutoLayout();

because the variable "aNewAutoLayout" is used to set the AutoLayout either for
pCurrentPage or for pHandoutMPage depending on bHandoutMode. And the variable
pUndoPage points to either pCurrentPage or pHandoutMPage depending on the same
variable bHandoutMode. So, I think that the commad above could be used to get
the old AutoLayout setting.

I'll attach a patch for this.
Comment 1 pmladek 2005-05-17 12:58:41 UTC
Created attachment 26228 [details]
This patch tries to fix the uninitialized variable.
Comment 2 wolframgarten 2005-05-17 13:03:51 UTC
Reassigned. Please handle this.
Comment 3 clippka 2005-09-09 13:32:46 UTC
André, please have a look
Comment 4 groucho266 2005-09-13 08:52:31 UTC
This old code certainly is not very beautifull but the compiler could have seen
that it is never executed.  The code line before the 
    if(bShowDialog) 
is
    sal_Bool bShowDialog(sal_False);

The aNewAutoLayout variable is correctly initialized when it later is used but
that is not detectable by the compiler.

So, the code in question should be removed and aNewAutoLayout should be properly
initialized to make the compiler happy.
Comment 5 clippka 2005-09-13 09:44:02 UTC
Changing target to OOo 3.0
Comment 6 groucho266 2006-07-04 15:34:51 UTC
Target change.
Comment 7 groucho266 2006-07-04 15:54:33 UTC
Target change.
Comment 8 Martin Hollmichel 2007-11-09 17:01:19 UTC
set target from 2.x to 3.x according
http://wiki.services.openoffice.org/wiki/Target_3x
Comment 9 Marcus 2017-05-20 10:47:45 UTC
Reset assigne to the default "issues@openoffice.apache.org".