Address some cppcheck warnings around initializers & catching by reference

This commit is contained in:
Brian Cox 2017-03-15 00:47:52 -07:00
parent 63168d9880
commit d3f859bfbd
10 changed files with 21 additions and 17 deletions

View File

@ -52,7 +52,7 @@
//========================================================================= //=========================================================================
cFCODataSourceIterImpl::cFCODataSourceIterImpl() cFCODataSourceIterImpl::cFCODataSourceIterImpl()
: mFlags(0) : mpErrorBucket(0), mFlags(0)
{ {
} }

View File

@ -99,14 +99,12 @@ cGenre::Genre cGenreSwitcher::GetDefaultGenre()
void cGenreSwitcher::RegisterGenre( const cGenreInfo* pGI, RegisterFlags flags /* = REGISTER_FLAGS_NONE */ ) void cGenreSwitcher::RegisterGenre( const cGenreInfo* pGI, RegisterFlags flags /* = REGISTER_FLAGS_NONE */ )
{ {
cDebug d("cGenreSwitcher::RegisterGenre"); cDebug d("cGenreSwitcher::RegisterGenre");
d.TraceDebug( _T("ID: %x, long name: %s, short name: %s\n"), pGI->m_ID, pGI->m_sLongName.c_str(), pGI->m_sShortName.c_str() );
//
// validate params
//
ASSERT( NULL != pGI ); ASSERT( NULL != pGI );
ASSERT( pGI->IsValid() ); ASSERT( pGI->IsValid() );
d.TraceDebug( _T("ID: %x, long name: %s, short name: %s\n"), pGI->m_ID, pGI->m_sLongName.c_str(), pGI->m_sShortName.c_str() );
// //
// can only be one of each genre ID // can only be one of each genre ID
// //

View File

@ -243,7 +243,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
ret = 8; ret = 8;
} }
catch (std::bad_alloc e) catch (std::bad_alloc& e)
{ {
// Note: We use fputs rather than TCERR as it will probably require the // Note: We use fputs rather than TCERR as it will probably require the
// least amount of memory to do its thing. If we ran out of memory we // least amount of memory to do its thing. If we ran out of memory we
@ -253,7 +253,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
ret = 8; ret = 8;
} }
catch (std::exception e) catch (std::exception& e)
{ {
TCERR << _T("*** Fatal exception: "); TCERR << _T("*** Fatal exception: ");
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;

View File

@ -1476,7 +1476,7 @@ public:
cFCOReportHeader* mpReportHeader; cFCOReportHeader* mpReportHeader;
// ctor can set up some default values // ctor can set up some default values
cTWModeDbUpdate_i() : cTWModeCommon(), mbInteractive(true), mbSecureMode(true), /*mSiteProvided(false),*/ mpReport(0), mpDbFile(0), mpReportHeader(0) {} cTWModeDbUpdate_i() : cTWModeCommon(), mbInteractive(true), mbSecureMode(true), mbEncryptDb(true), /*mSiteProvided(false),*/ mpReport(0), mpDbFile(0), mpReportHeader(0) {}
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -182,14 +182,17 @@ class cTWModeCommon
bool mMailNoViolations; // Email out reports with no violations? bool mMailNoViolations; // Email out reports with no violations?
TSTRING mMailFrom; TSTRING mMailFrom;
cTWModeCommon() : mVerbosity(1), cTWModeCommon() : mVerbosity(1),
mLocalProvided(false), mLocalProvided(false),
mbLatePassphrase(false), mbLatePassphrase(false),
mfLooseDirs(false), mfLooseDirs(false),
mbResetAccessTime(false), mbResetAccessTime(false),
mbLogToSyslog(false), mbLogToSyslog(false),
mbCrossFileSystems(false), mbCrossFileSystems(false),
mbDirectIO(false) mbDirectIO(false),
mMailMethod(cMailMessage::NO_METHOD),
mSmtpPort(25),
mMailNoViolations(true)
{ {
} }
}; };

View File

@ -61,7 +61,8 @@ cFileManipulator::cFileManipulator(const TCHAR* filename)
} }
cFileManipulator::cFileManipulator(const cFileManipulator& rhs) cFileManipulator::cFileManipulator(const cFileManipulator& rhs)
: mFileName(rhs.mFileName), : mbInit(false),
mFileName(rhs.mFileName),
mFileHeader(rhs.mFileHeader) mFileHeader(rhs.mFileHeader)
{ {
} }

View File

@ -143,7 +143,8 @@ int cTextReportViewer::Init( const cFCOReportHeader& h, cFCOReport& r )
{ {
mpHeader = &h; mpHeader = &h;
mpReport = &r; mpReport = &r;
mpOut = NULL; mpOut = NULL;
mpIn = NULL;
mpCurPD = NULL; mpCurPD = NULL;
mpCurNT = NULL; mpCurNT = NULL;
mfUpdate = false; mfUpdate = false;
@ -152,6 +153,7 @@ int cTextReportViewer::Init( const cFCOReportHeader& h, cFCOReport& r )
mErrorNum = 1; mErrorNum = 1;
mReportingLevel = FULL_REPORT; mReportingLevel = FULL_REPORT;
mfGotNumbers = false; mfGotNumbers = false;
mCurrentChar[0] = '\0';
mCurrentCharSize = 0; mCurrentCharSize = 0;
return 0; return 0;
} }

View File

@ -153,7 +153,7 @@ protected:
int mChangedObjects; int mChangedObjects;
TSTRING mStartPoint; TSTRING mStartPoint;
RuleSummaryLine() {} RuleSummaryLine() : mSeverity(0), mAddedObjects(0), mRemovedObjects(0), mChangedObjects(0) {}
RuleSummaryLine(const RuleSummaryLine& rhs) { *this = rhs; } RuleSummaryLine(const RuleSummaryLine& rhs) { *this = rhs; }
void operator = (const RuleSummaryLine& rhs) void operator = (const RuleSummaryLine& rhs)
{ {

View File

@ -203,14 +203,14 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
ret = 1; ret = 1;
} }
catch (std::bad_alloc e) catch (std::bad_alloc& e)
{ {
TCERR << _T("*** Fatal exception: Out of memory "); TCERR << _T("*** Fatal exception: Out of memory ");
TCERR << _T("*** Exiting...\n"); TCERR << _T("*** Exiting...\n");
ret = 1; ret = 1;
} }
catch (std::exception e) catch (std::exception& e)
{ {
TCERR << _T("*** Fatal exception: "); TCERR << _T("*** Fatal exception: ");
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;

View File

@ -217,14 +217,14 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ] )
ret = 1; ret = 1;
} }
catch (std::bad_alloc e) catch (std::bad_alloc& e)
{ {
TCERR << _T("*** Fatal exception: Out of memory "); TCERR << _T("*** Fatal exception: Out of memory ");
TCERR << _T("*** Exiting...\n"); TCERR << _T("*** Exiting...\n");
ret = 1; ret = 1;
} }
catch (std::exception e) catch (std::exception& e)
{ {
TCERR << _T("*** Fatal exception: "); TCERR << _T("*** Fatal exception: ");
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;