Skip to content
Browse files

Fix some minor issues

E.g. a gcc warning about an uninitialized variable.

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
1 parent f44f307 commit 5f53c3509f38e5a0c1c24672607b0cb7ead7e565 @psychon psychon committed Aug 21, 2011
Showing with 59 additions and 49 deletions.
  1. +32 −31 ClientCommand.cpp
  2. +13 −12 Modules.cpp
  3. +8 −0 Modules.h
  4. +6 −6 modules/webadmin.cpp
View
63 ClientCommand.cpp
@@ -575,10 +575,12 @@ void CClient::UserCommand(CString& sLine) {
sMod = sType;
sArgs = sLine.Token(2, true);
sType = "default";
+ // Will be set correctly later
+ eType = ModuleTypeUser;
}
if (m_pUser->DenyLoadMod()) {
- PutStatus("Unable to load [" + sMod + "] Access Denied.");
+ PutStatus("Unable to load [" + sMod + "]: Access Denied.");
return;
}
@@ -599,23 +601,22 @@ void CClient::UserCommand(CString& sLine) {
}
if (eType == ModuleTypeGlobal && !m_pUser->IsAdmin()) {
- PutStatus("Unable to load global module [" + sMod + "] Access Denied.");
+ PutStatus("Unable to load global module [" + sMod + "]: Access Denied.");
return;
}
CString sModRet;
bool b = false;
switch (eType) {
- case ModuleTypeGlobal:
- b = CZNC::Get().GetModules().LoadModule(sMod, sArgs, eType, NULL, sModRet);
- break;
- case ModuleTypeUser:
- b = m_pUser->GetModules().LoadModule(sMod, sArgs, eType, m_pUser, sModRet);
- break;
- default:
- sModRet = "Unable to load module [" + sMod + "] Unknown module type";
-
+ case ModuleTypeGlobal:
+ b = CZNC::Get().GetModules().LoadModule(sMod, sArgs, eType, NULL, sModRet);
+ break;
+ case ModuleTypeUser:
+ b = m_pUser->GetModules().LoadModule(sMod, sArgs, eType, m_pUser, sModRet);
+ break;
+ default:
+ sModRet = "Unable to load module [" + sMod + "]: Unknown module type";
}
if (b)
@@ -659,22 +660,21 @@ void CClient::UserCommand(CString& sLine) {
}
if (eType == ModuleTypeGlobal && !m_pUser->IsAdmin()) {
- PutStatus("Unable to unload global module [" + sMod + "] Access Denied.");
+ PutStatus("Unable to unload global module [" + sMod + "]: Access Denied.");
return;
}
CString sModRet;
switch (eType) {
- case ModuleTypeGlobal:
- CZNC::Get().GetModules().UnloadModule(sMod, sModRet);
- break;
- case ModuleTypeUser:
- m_pUser->GetModules().UnloadModule(sMod, sModRet);
- break;
- default:
- sModRet = "Unable to unload module [" + sMod + "] Unknown module type";
-
+ case ModuleTypeGlobal:
+ CZNC::Get().GetModules().UnloadModule(sMod, sModRet);
+ break;
+ case ModuleTypeUser:
+ m_pUser->GetModules().UnloadModule(sMod, sModRet);
+ break;
+ default:
+ sModRet = "Unable to unload module [" + sMod + "]: Unknown module type";
}
PutStatus(sModRet);
@@ -698,6 +698,8 @@ void CClient::UserCommand(CString& sLine) {
sMod = sType;
sArgs = sLine.Token(2, true);
sType = "default";
+ // Will be set correctly later
+ eType = ModuleTypeUser;
}
if (sMod.empty()) {
@@ -717,22 +719,21 @@ void CClient::UserCommand(CString& sLine) {
}
if (eType == ModuleTypeGlobal && !m_pUser->IsAdmin()) {
- PutStatus("Unable to reload global module [" + sMod + "] Access Denied.");
+ PutStatus("Unable to reload global module [" + sMod + "]: Access Denied.");
return;
}
CString sModRet;
switch (eType) {
- case ModuleTypeGlobal:
- CZNC::Get().GetModules().ReloadModule(sMod, sArgs, NULL, sModRet);
- break;
- case ModuleTypeUser:
- m_pUser->GetModules().ReloadModule(sMod, sArgs, m_pUser, sModRet);
- break;
- default:
- sModRet = "Unable to reload module [" + sMod + "] Unknown module type";
-
+ case ModuleTypeGlobal:
+ CZNC::Get().GetModules().ReloadModule(sMod, sArgs, NULL, sModRet);
+ break;
+ case ModuleTypeUser:
+ m_pUser->GetModules().ReloadModule(sMod, sArgs, m_pUser, sModRet);
+ break;
+ default:
+ sModRet = "Unable to reload module [" + sMod + "]: Unknown module type";
}
PutStatus(sModRet);
View
25 Modules.cpp
@@ -832,29 +832,30 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, EModuleT
if (!Info.SupportsType(eType)) {
dlclose(p);
- sRetMsg = "Module [" + sModule + "] does not support module type.";
+ sRetMsg = "Module [" + sModule + "] does not support module type ["
+ + CModInfo::ModuleTypeToString(eType) + "].";
return false;
}
if (!pUser && eType == ModuleTypeUser) {
dlclose(p);
- sRetMsg = "Module [" + sModule + "] require a user.";
+ sRetMsg = "Module [" + sModule + "] requires a user.";
return false;
}
CModule* pModule = NULL;
switch (eType) {
- case ModuleTypeUser:
- pModule = Info.GetLoader()(p, pUser, sModule, sDataPath);
- break;
- case ModuleTypeGlobal:
- pModule = Info.GetGlobalLoader()(p, sModule, sDataPath);
- break;
- default:
- dlclose(p);
- sRetMsg = "Unsupported module type";
- return false;
+ case ModuleTypeUser:
+ pModule = Info.GetLoader()(p, pUser, sModule, sDataPath);
+ break;
+ case ModuleTypeGlobal:
+ pModule = Info.GetGlobalLoader()(p, sModule, sDataPath);
+ break;
+ default:
+ dlclose(p);
+ sRetMsg = "Unsupported module type";
+ return false;
}
pModule->SetDescription(Info.GetDescription());
View
8 Modules.h
@@ -207,6 +207,14 @@ class CModInfo {
return *m_seType.begin();
}
+ static CString ModuleTypeToString(EModuleType eType) {
+ switch (eType) {
+ case ModuleTypeGlobal: return "Global";
+ case ModuleTypeUser: return "User";
+ default: return "UNKNOWN";
+ }
+ }
+
// Getters
const CString& GetName() const { return m_sName; }
const CString& GetPath() const { return m_sPath; }
View
12 modules/webadmin.cpp
@@ -728,12 +728,12 @@ class CWebAdminMod : public CModule {
l["Description"] = Info.GetDescription();
l["Wiki"] = Info.GetWikiPage();
- if (pUser && pUser->GetModules().FindModule(Info.GetName())) {
- CModule *pModule = pUser->GetModules().FindModule(Info.GetName());
- if (pModule) {
- l["Checked"] = "true";
- l["Args"] = pModule->GetArgs();
- }
+ CModule *pModule = NULL;
+ if (pUser)
+ pModule = pUser->GetModules().FindModule(Info.GetName());
+ if (pModule) {
+ l["Checked"] = "true";
+ l["Args"] = pModule->GetArgs();
}
if (!spSession->IsAdmin() && pUser && pUser->DenyLoadMod()) {

0 comments on commit 5f53c35

Please sign in to comment.
Something went wrong with that request. Please try again.