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()
: 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 */ )
{
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( 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
//

View File

@ -243,7 +243,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
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
// 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;
}
catch (std::exception e)
catch (std::exception& e)
{
TCERR << _T("*** Fatal exception: ");
std::cerr << e.what() << std::endl;

View File

@ -1476,7 +1476,7 @@ public:
cFCOReportHeader* mpReportHeader;
// 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?
TSTRING mMailFrom;
cTWModeCommon() : mVerbosity(1),
cTWModeCommon() : mVerbosity(1),
mLocalProvided(false),
mbLatePassphrase(false),
mfLooseDirs(false),
mbResetAccessTime(false),
mbLogToSyslog(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)
: mFileName(rhs.mFileName),
: mbInit(false),
mFileName(rhs.mFileName),
mFileHeader(rhs.mFileHeader)
{
}

View File

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

View File

@ -153,7 +153,7 @@ protected:
int mChangedObjects;
TSTRING mStartPoint;
RuleSummaryLine() {}
RuleSummaryLine() : mSeverity(0), mAddedObjects(0), mRemovedObjects(0), mChangedObjects(0) {}
RuleSummaryLine(const RuleSummaryLine& rhs) { *this = 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;
}
catch (std::bad_alloc e)
catch (std::bad_alloc& e)
{
TCERR << _T("*** Fatal exception: Out of memory ");
TCERR << _T("*** Exiting...\n");
ret = 1;
}
catch (std::exception e)
catch (std::exception& e)
{
TCERR << _T("*** Fatal exception: ");
std::cerr << e.what() << std::endl;

View File

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