Permalink
Browse files

Silence some wrong compiler warnings

For every available module call implementation, we got this:

Modules.cpp: In member function ‘bool CModules::OnGetAvailableMods(std::__debug::set<CModInfo>&, CModInfo::EModuleType)’:
Modules.cpp:149:72: error: ‘pNetwork’ may be used uninitialized in this function [-Werror=uninitialized]
Modules.cpp:808:260: note: ‘pNetwork’ was declared here
Modules.cpp:148:54: error: ‘pOldUser’ may be used uninitialized in this function [-Werror=uninitialized]
Modules.cpp:808:168: note: ‘pOldUser’ was declared here

I guess GCC saw that m_pNetwork and m_pUser could be changed by the module call
to a non-NULL value which means we would really use an uninitialized value...

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
1 parent dc33283 commit 601692999d3328204c99550058a51c5a33755565 @psychon psychon committed Aug 29, 2011
Showing with 4 additions and 4 deletions.
  1. +4 −4 Modules.cpp
View
@@ -26,12 +26,12 @@
CModule* pMod = (CModule *) (*this)[a]; \
CClient* pOldClient = pMod->GetClient(); \
pMod->SetClient(m_pClient); \
- CUser* pOldUser; \
+ CUser* pOldUser = NULL; \
if (m_pUser) { \
pOldUser = pMod->GetUser(); \
pMod->SetUser(m_pUser); \
} \
- CIRCNetwork* pNetwork; \
+ CIRCNetwork* pNetwork = NULL; \
if (m_pNetwork) { \
pNetwork = pMod->GetNetwork(); \
pMod->SetNetwork(m_pNetwork); \
@@ -58,12 +58,12 @@
CModule::EModRet e = CModule::CONTINUE; \
CClient* pOldClient = pMod->GetClient(); \
pMod->SetClient(m_pClient); \
- CUser* pOldUser; \
+ CUser* pOldUser = NULL; \
if (m_pUser) { \
pOldUser = pMod->GetUser(); \
pMod->SetUser(m_pUser); \
} \
- CIRCNetwork* pNetwork; \
+ CIRCNetwork* pNetwork = NULL; \
if (m_pNetwork) { \
pNetwork = pMod->GetNetwork(); \
pMod->SetNetwork(m_pNetwork); \

0 comments on commit 6016929

Please sign in to comment.