Fix some Coverity uninitialized field warnings.

Fixes Coverity CIDs:

- 175824
- 169337
- 163191
- 175827
- 175440
- 175438
- 157136
This commit is contained in:
Wayne Stambaugh 2018-06-04 13:48:17 -04:00
parent 5dbfa6a9c1
commit 7343e78347
7 changed files with 94 additions and 82 deletions

View File

@ -1,5 +1,7 @@
/* /*
* Copyright (C) 2018 CERN * Copyright (C) 2018 CERN
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* Author: Maciej Suminski <maciej.suminski@cern.ch> * Author: Maciej Suminski <maciej.suminski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -27,6 +29,8 @@ DIALOG_FILE_DIR_PICKER::DIALOG_FILE_DIR_PICKER( wxWindow* parent, const wxString
: DIALOG_SHIM( parent, wxID_ANY, title, wxDefaultPosition, : DIALOG_SHIM( parent, wxID_ANY, title, wxDefaultPosition,
wxSize( 500, 600 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) wxSize( 500, 600 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{ {
m_showHidden = nullptr;
wxString path = defaultPath.IsEmpty() ? wxGetCwd() : defaultPath; wxString path = defaultPath.IsEmpty() ? wxGetCwd() : defaultPath;
m_filesOnly = style & FD_RETURN_FILESONLY; m_filesOnly = style & FD_RETURN_FILESONLY;

View File

@ -105,11 +105,12 @@ int CMP_TREE_NODE::Compare( CMP_TREE_NODE const& aNode1, CMP_TREE_NODE const& aN
CMP_TREE_NODE::CMP_TREE_NODE() CMP_TREE_NODE::CMP_TREE_NODE()
: Parent( nullptr ), : Parent( nullptr ),
Type( INVALID ), Type( INVALID ),
IntrinsicRank( 0 ), IntrinsicRank( 0 ),
Score( kLowestDefaultScore ), Score( kLowestDefaultScore ),
Unit( 0 ), SearchTextNormalized( false ),
IsRoot( false ) Unit( 0 ),
IsRoot( false )
{} {}

View File

@ -115,7 +115,8 @@ protected:
public: public:
FIELDS_EDITOR_GRID_DATA_MODEL( SCH_EDIT_FRAME* aFrame, SCH_REFERENCE_LIST& aComponentList ) : FIELDS_EDITOR_GRID_DATA_MODEL( SCH_EDIT_FRAME* aFrame, SCH_REFERENCE_LIST& aComponentList ) :
m_frame( aFrame ), m_frame( aFrame ),
m_componentRefs( aComponentList ) m_componentRefs( aComponentList ),
m_sortAscending( false )
{ {
m_componentRefs.SplitReferences(); m_componentRefs.SplitReferences();
} }

View File

@ -2,6 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2016-2018 CERN * Copyright (C) 2016-2018 CERN
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
@ -37,7 +39,8 @@ using namespace std;
static const wxChar* const traceNgspice = wxT( "KICAD_NGSPICE" ); static const wxChar* const traceNgspice = wxT( "KICAD_NGSPICE" );
NGSPICE::NGSPICE() NGSPICE::NGSPICE() :
m_error( false )
{ {
init_dll(); init_dll();
} }

View File

@ -96,6 +96,7 @@ public:
aMainText, aMainText, aMainText, aMainText,
aMainPos, aMainPos ); aMainPos, aMainPos );
m_hasSecondItem = false; m_hasSecondItem = false;
m_parent = nullptr;
} }
/** /**

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012-2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2012-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017 CERN * Copyright (C) 2017 CERN
* @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com> * @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
* *
@ -214,6 +214,7 @@ public:
*/ */
OPTIONAL_XML_ATTRIBUTE( const wxString& aData ) OPTIONAL_XML_ATTRIBUTE( const wxString& aData )
{ {
m_data = T();
m_isAvailable = !aData.IsEmpty(); m_isAvailable = !aData.IsEmpty();
if( m_isAvailable ) if( m_isAvailable )

View File

@ -80,12 +80,13 @@ namespace numEval
struct TokenType struct TokenType
{ {
union { union {
double dValue; double dValue;
int iValue; int iValue;
}; };
bool valid;
char text[32]; bool valid;
char text[32];
}; };
} // namespace numEval } // namespace numEval
@ -94,101 +95,101 @@ class NumericEvaluator {
enum class Unit { Invalid, Metric, Inch, Mil }; enum class Unit { Invalid, Metric, Inch, Mil };
public: public:
NumericEvaluator(); NumericEvaluator();
~NumericEvaluator(); ~NumericEvaluator();
/* Initialization and destruction. init() is invoked be the constructor and should not be needed /* Initialization and destruction. init() is invoked be the constructor and should not be needed
* by the user. * by the user.
* clear() should be invoked by the user if a new input string is to be processed. It will reset * clear() should be invoked by the user if a new input string is to be processed. It will reset
* the parser and clear the original expression value for a requested object (if pObj != null). * the parser and clear the original expression value for a requested object (if pObj != null).
*/ */
void init(); void init();
void clear(const void* pObj = nullptr); void clear(const void* pObj = nullptr);
/* Set the decimal separator for the input string. Defaults to '.' */ /* Set the decimal separator for the input string. Defaults to '.' */
void setDecimalSeparator(char sep); void setDecimalSeparator(char sep);
/* Enable or disable support for input string storage. /* Enable or disable support for input string storage.
* If enabled the input string is saved if process(const char*, const void*) is used. * If enabled the input string is saved if process(const char*, const void*) is used.
*/ */
void enableTextInputStorage(bool w) { bClTextInputStorage = w; } void enableTextInputStorage(bool w) { bClTextInputStorage = w; }
/* Used by the lemon parser */ /* Used by the lemon parser */
void parseError(const char* s); void parseError(const char* s);
void parseOk(); void parseOk();
void parseSetResult(double); void parseSetResult(double);
/* Check if previous invokation of process() was successful */ /* Check if previous invokation of process() was successful */
inline bool isValid() const { return !bClError; } inline bool isValid() const { return !bClError; }
/* Result of string processing. Undefined if !isValid() */ /* Result of string processing. Undefined if !isValid() */
inline const char* result() const { return clToken.token; } inline const char* result() const { return clToken.token; }
/* Evaluate input string. /* Evaluate input string.
* Result can be retrieved by result(). * Result can be retrieved by result().
* Returns true if input string could be evaluated, otherwise false. * Returns true if input string could be evaluated, otherwise false.
*/ */
bool process(const char* s); bool process(const char* s);
/* Like process(const char*) but also stores input string in a std:map with key pObj. */ /* Like process(const char*) but also stores input string in a std:map with key pObj. */
bool process(const char* s, const void* pObj); bool process(const char* s, const void* pObj);
/* Retrieve old input string with key pObj. */ /* Retrieve old input string with key pObj. */
const char* textInput(const void* pObj) const; const char* textInput(const void* pObj) const;
/* Add/set variable with value */ /* Add/set variable with value */
void setVar(const std::string&, double value); void setVar(const std::string&, double value);
/* Get value of variable. Returns 0.0 if not defined. */ /* Get value of variable. Returns 0.0 if not defined. */
double getVar(const std::string&); double getVar(const std::string&);
/* Remove single variable */ /* Remove single variable */
void removeVar(const std::string& s) { clVarMap.erase(s); } void removeVar(const std::string& s) { clVarMap.erase(s); }
/* Remove all variables */ /* Remove all variables */
void clearVar() { clVarMap.clear(); } void clearVar() { clVarMap.clear(); }
protected: protected:
/* Token type used by the tokenizer */ /* Token type used by the tokenizer */
struct Token { struct Token {
int token; int token;
numEval::TokenType value; numEval::TokenType value;
}; };
/* Begin processing of a new input string */ /* Begin processing of a new input string */
void newString(const char* s); void newString(const char* s);
/* Tokenizer: Next token/value taken from input string. */ /* Tokenizer: Next token/value taken from input string. */
Token getToken(); Token getToken();
/* Used by processing loop */ /* Used by processing loop */
void parse(int token, numEval::TokenType value); void parse(int token, numEval::TokenType value);
private: private:
void* pClParser; // the current lemon parser state machine void* pClParser; // the current lemon parser state machine
/* Token state for input string. */ /* Token state for input string. */
struct TokenStat { struct TokenStat {
enum { OutLen=32 }; enum { OutLen=32 };
TokenStat() : input(0), token(0), inputLen(0) { /* empty */ } TokenStat() : input(0), token(0), inputLen(0), pos(0) { /* empty */ }
const char* input; // current input string ("var=4") const char* input; // current input string ("var=4")
char* token; // output token ("var", type:VAR; "4", type:VALUE) char* token; // output token ("var", type:VAR; "4", type:VALUE)
size_t inputLen; // strlen(input) size_t inputLen; // strlen(input)
size_t pos; // current index size_t pos; // current index
} clToken; } clToken;
char cClDecSep; // decimal separator ('.') char cClDecSep; // decimal separator ('.')
/* Parse progress. Set by parser actions. */ /* Parse progress. Set by parser actions. */
bool bClError; bool bClError;
bool bClParseFinished; bool bClParseFinished;
bool bClTextInputStorage; // Enable input string storage used by process(const char*, const void*) bool bClTextInputStorage; // Enable input string storage used by process(const char*, const void*)
Unit eClUnitDefault; // Default unit for values Unit eClUnitDefault; // Default unit for values
std::map<const void*, std::string> clObjMap; // Map pointer to text entry -> (original) input string std::map<const void*, std::string> clObjMap; // Map pointer to text entry -> (original) input string
std::map<std::string, double> clVarMap; std::map<std::string, double> clVarMap;
}; };