Menu

#1 found a lots of uninitialized variables

closed-fixed
nobody
None
5
2009-08-04
2009-08-01
orbitcowboy
No

Hello,

i have checked the sources with the static code analysis tool cppcheck.
It detected a lots of uninitialized variables in constructors of several classes:

Here is the output:

puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_complete'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_time'
puz/XPuzzle.hpp,36,style,Member variable not initialized in the constructor 'XPuzzle::m_modified'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_incorrectSquares'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_blankSquares'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_direction'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_focusedEnd'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_focusedStart'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_focusedSquare'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_grid'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_fit'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_lastBoxSize'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_boxSize'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_borderSize'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_incorrectSquares'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_blankSquares'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_direction'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_focusedEnd'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_focusedStart'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_focusedSquare'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_grid'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_fit'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_lastBoxSize'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_boxSize'
XGridCtrl.hpp,73,style,Member variable not initialized in the constructor 'XGridCtrl::m_borderSize'
ClueListBox.hpp,46,style,Member variable not initialized in the constructor 'ClueListBox::m_numWidth'
ClueListBox.hpp,48,style,Member variable not initialized in the constructor 'ClueListBox::m_numWidth'
ClueListBox.hpp,46,style,Member variable not initialized in the constructor 'ClueListBox::m_numWidth'
ClueListBox.hpp,48,style,Member variable not initialized in the constructor 'ClueListBox::m_numWidth'
ClueListBox.hpp,46,style,Member variable not initialized in the constructor 'ClueListBox::m_numWidth'
ClueListBox.hpp,48,style,Member variable not initialized in the constructor 'ClueListBox::m_numWidth'
CluePanel.hpp,40,style,Member variable not initialized in the constructor 'CluePanel::m_direction'
CluePanel.hpp,40,style,Member variable not initialized in the constructor 'CluePanel::m_direction'
utils/ToolManager.cpp,21,style,Member variable not initialized in the constructor 'ToolManager::m_auiIconSize'
utils/ToolManager.cpp,21,style,Member variable not initialized in the constructor 'ToolManager::m_tbIconSize'
utils/ToolManager.cpp,21,style,Member variable not initialized in the constructor 'ToolManager::m_menuIconSize'

As far as i can see, this is easy to fix.

Best regards

Martin

Discussion

  • wackymorningdj

    wackymorningdj - 2009-08-04
    • status: open --> closed-fixed
     
  • wackymorningdj

    wackymorningdj - 2009-08-04

    Hi there. Thanks for taking a quick look at the code. I went ahead and grabbed a copy of cppcheck as well -- looks like a good tool.

    It's not exactly suited for wxWidgets development though, because of how wxWidgets implements constructors (I used the same paradigm for XGridCtrl, for example). Most everything is initialized in an Init() method in this class, and it looks like cppcheck overlooked that.

    That said, the entries for XPuzzle, CluePanel, ClueListBox, and ToolManager are all valid (though most of them are duplicates). None of them are a real problem since all of the variables are set later in the code well before they are accessed.

    I went ahead and changed the code so that all of those variables are initialized in either the constructor or an Init() method. It's in the latest SVN.

    Thanks,

    Mike

     

Log in to post a comment.