Use nullptr (#816)

Changes applied by 'clang-modernize -use-nullptr [...]'
This commit is contained in:
J-P Nurmi
2015-02-25 09:19:28 +01:00
parent 26cc16caa7
commit 70c0ffb10b
38 changed files with 246 additions and 246 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ class CClient;
class CBufLine {
public:
CBufLine() { throw 0; } // shouldn't be called, but is needed for compilation
CBufLine(const CString& sFormat, const CString& sText = "", const timeval* ts = 0);
CBufLine(const CString& sFormat, const CString& sText = "", const timeval* ts = nullptr);
~CBufLine();
CString GetLine(const CClient& Client, const MCString& msParams) const;
void UpdateTime();
@@ -58,7 +58,7 @@ public:
CBuffer(unsigned int uLineCount = 100);
~CBuffer();
size_type AddLine(const CString& sFormat, const CString& sText = "", const timeval* ts = 0);
size_type AddLine(const CString& sFormat, const CString& sText = "", const timeval* ts = nullptr);
/// Same as AddLine, but replaces a line whose format string starts with sMatch if there is one.
size_type UpdateLine(const CString& sMatch, const CString& sFormat, const CString& sText = "");
/// Same as UpdateLine, but does nothing if this exact line already exists.
+4 -4
View File
@@ -56,7 +56,7 @@ public:
M_Except = 'e'
} EModes;
CChan(const CString& sName, CIRCNetwork* pNetwork, bool bInConfig, CConfig *pConfig = NULL);
CChan(const CString& sName, CIRCNetwork* pNetwork, bool bInConfig, CConfig *pConfig = nullptr);
~CChan();
CChan(const CChan&) = delete;
@@ -67,14 +67,14 @@ public:
void Clone(CChan& chan);
void Cycle() const;
void JoinUser(const CString& sKey = "");
void AttachUser(CClient* pClient = NULL);
void AttachUser(CClient* pClient = nullptr);
void DetachUser();
void OnWho(const CString& sNick, const CString& sIdent, const CString& sHost);
// Modes
void SetModes(const CString& s);
void ModeChange(const CString& sModes, const CNick* OpNick = NULL);
void ModeChange(const CString& sModes, const CNick* OpNick = nullptr);
bool AddMode(unsigned char uMode, const CString& sArg);
bool RemMode(unsigned char uMode);
CString GetModeString() const;
@@ -97,7 +97,7 @@ public:
unsigned int GetBufferCount() const { return m_Buffer.GetLineCount(); }
bool SetBufferCount(unsigned int u, bool bForce = false) { m_bHasBufferCountSet = true; return m_Buffer.SetLineCount(u, bForce); }
void InheritBufferCount(unsigned int u, bool bForce = false) { if (!m_bHasBufferCountSet) m_Buffer.SetLineCount(u, bForce); }
size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = NULL) { return m_Buffer.AddLine(sFormat, sText, ts); }
size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = nullptr) { return m_Buffer.AddLine(sFormat, sText, ts); }
void ClearBuffer() { m_Buffer.Clear(); }
void SendBuffer(CClient* pClient);
void SendBuffer(CClient* pClient, const CBuffer& Buffer);
+4 -4
View File
@@ -80,7 +80,7 @@ public:
CClientAuth(const CClientAuth&) = delete;
CClientAuth& operator=(const CClientAuth&) = delete;
void Invalidate() { m_pClient = NULL; CAuthBase::Invalidate(); }
void Invalidate() { m_pClient = nullptr; CAuthBase::Invalidate(); }
void AcceptedLogin(CUser& User);
void RefusedLogin(const CString& sReason);
private:
@@ -91,8 +91,8 @@ protected:
class CClient : public CIRCSocket {
public:
CClient() : CIRCSocket() {
m_pUser = NULL;
m_pNetwork = NULL;
m_pUser = nullptr;
m_pNetwork = nullptr;
m_bGotPass = false;
m_bGotNick = false;
m_bGotUser = false;
@@ -137,7 +137,7 @@ public:
void UserPortCommand(CString& sLine);
void StatusCTCP(const CString& sCommand);
void BouncedOff();
bool IsAttached() const { return m_pUser != NULL; }
bool IsAttached() const { return m_pUser != nullptr; }
bool IsPlaybackActive() const { return m_bPlaybackActive; }
void SetPlaybackActive(bool bActive) { m_bPlaybackActive = bActive; }
+2 -2
View File
@@ -188,7 +188,7 @@ public:
struct dirent * de;
while ((de = readdir(dir)) != 0) {
while ((de = readdir(dir)) != nullptr) {
if ((strcmp(de->d_name, ".") == 0) || (strcmp(de->d_name, "..") == 0)) {
continue;
}
@@ -249,7 +249,7 @@ public:
static CString GetCWD() {
CString sRet;
char * pszCurDir = getcwd(NULL, 0);
char * pszCurDir = getcwd(nullptr, 0);
if (pszCurDir) {
sRet = pszCurDir;
free(pszCurDir);
+3 -3
View File
@@ -89,9 +89,9 @@ public:
const CModules& GetModules() const { return *m_pModules; }
// !Modules
bool PutUser(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutStatus(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutModule(const CString& sModule, const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutUser(const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool PutStatus(const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool PutModule(const CString& sModule, const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
const std::vector<CChan*>& GetChans() const;
CChan* FindChan(CString sName) const;
+1 -1
View File
@@ -38,7 +38,7 @@ public:
m_bSSL = bSSL;
m_eAddr = eAddr;
m_sURIPrefix = sURIPrefix;
m_pListener = NULL;
m_pListener = nullptr;
m_eAcceptType = eAccept;
}
+3 -3
View File
@@ -166,7 +166,7 @@ class CFPTimer : public CTimer {
public:
CFPTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription)
: CTimer(pModule, uInterval, uCycles, sLabel, sDescription) {
m_pFBCallback = NULL;
m_pFBCallback = nullptr;
}
virtual ~CFPTimer() {}
@@ -221,13 +221,13 @@ public:
} EModuleType;
CModInfo() {
m_fLoader = NULL;
m_fLoader = nullptr;
m_bHasArgs = false;
}
CModInfo(const CString& sName, const CString& sPath, EModuleType eType) {
m_sName = sName;
m_sPath = sPath;
m_fLoader = NULL;
m_fLoader = nullptr;
m_bHasArgs = false;
}
~CModInfo() {}
+1 -1
View File
@@ -35,7 +35,7 @@ public:
const CBuffer& GetBuffer() const { return m_Buffer; }
unsigned int GetBufferCount() const { return m_Buffer.GetLineCount(); }
bool SetBufferCount(unsigned int u, bool bForce = false) { return m_Buffer.SetLineCount(u, bForce); }
size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = NULL) { return m_Buffer.AddLine(sFormat, sText, ts); }
size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = nullptr) { return m_Buffer.AddLine(sFormat, sText, ts); }
void ClearBuffer() { m_Buffer.Clear(); }
void SendBuffer(CClient* pClient);
void SendBuffer(CClient* pClient, const CBuffer& Buffer);
+5 -5
View File
@@ -67,7 +67,7 @@ public:
CSockManager();
virtual ~CSockManager();
bool ListenHost(u_short iPort, const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
bool ListenHost(u_short iPort, const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = nullptr, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
CSListener L(iPort, sBindHost);
L.SetSockName(sSockName);
@@ -92,11 +92,11 @@ public:
return Listen(L, pcSock);
}
bool ListenAll(u_short iPort, const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
bool ListenAll(u_short iPort, const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = nullptr, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
return ListenHost(iPort, sSockName, "", bSSL, iMaxConns, pcSock, iTimeout, eAddr);
}
u_short ListenRand(const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
u_short ListenRand(const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = nullptr, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
unsigned short uPort = 0;
CSListener L(0, sBindHost);
@@ -124,11 +124,11 @@ public:
return uPort;
}
u_short ListenAllRand(const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
u_short ListenAllRand(const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = nullptr, u_int iTimeout = 0, EAddrType eAddr = ADDR_ALL) {
return(ListenRand(sSockName, "", bSSL, iMaxConns, pcSock, iTimeout, eAddr));
}
void Connect(const CString& sHostname, u_short iPort, const CString& sSockName, int iTimeout = 60, bool bSSL = false, const CString& sBindHost = "", CZNCSock *pcSock = NULL);
void Connect(const CString& sHostname, u_short iPort, const CString& sSockName, int iTimeout = 60, bool bSSL = false, const CString& sBindHost = "", CZNCSock *pcSock = nullptr);
unsigned int GetAnonConnectionCount(const CString &sIP) const;
private:
+1 -1
View File
@@ -128,7 +128,7 @@ public:
Init();
}
CTemplate(const std::shared_ptr<CTemplateOptions>& Options, CTemplate* pParent = NULL) : MCString(), m_spOptions(Options) {
CTemplate(const std::shared_ptr<CTemplateOptions>& Options, CTemplate* pParent = nullptr) : MCString(), m_spOptions(Options) {
Init();
m_pParent = pParent;
}
+5 -5
View File
@@ -39,7 +39,7 @@ public:
friend class CConditionVariable;
CMutex() {
int i = pthread_mutex_init(&m_mutex, NULL);
int i = pthread_mutex_init(&m_mutex, nullptr);
if (i) {
CUtils::PrintError("Can't initialize mutex: " + CString(strerror(errno)));
exit(1);
@@ -124,7 +124,7 @@ private:
class CConditionVariable {
public:
CConditionVariable() {
int i = pthread_cond_init(&m_cond, NULL);
int i = pthread_cond_init(&m_cond, nullptr);
if (i) {
CUtils::PrintError("Can't initialize condition variable: "
+ CString(strerror(errno)));
@@ -188,8 +188,8 @@ public:
*/
int i = sigfillset(&sigmask);
i |= pthread_sigmask(SIG_SETMASK, &sigmask, &old_sigmask);
i |= pthread_create(&thr, NULL, func, arg);
i |= pthread_sigmask(SIG_SETMASK, &old_sigmask, NULL);
i |= pthread_create(&thr, nullptr, func, arg);
i |= pthread_sigmask(SIG_SETMASK, &old_sigmask, nullptr);
i |= pthread_detach(thr);
if (i) {
CUtils::PrintError("Can't start new thread: "
@@ -295,7 +295,7 @@ private:
static void *threadPoolFunc(void *arg) {
CThreadPool &pool = *reinterpret_cast<CThreadPool *>(arg);
pool.threadFunc();
return NULL;
return nullptr;
}
// mutex protecting all of these members
+6 -6
View File
@@ -83,12 +83,12 @@ public:
bool HasSpaceForNewNetwork() const;
// !Networks
bool PutUser(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutAllUser(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutStatus(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutStatusNotice(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutModule(const CString& sModule, const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutModNotice(const CString& sModule, const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL);
bool PutUser(const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool PutAllUser(const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool PutStatus(const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool PutStatusNotice(const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool PutModule(const CString& sModule, const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool PutModNotice(const CString& sModule, const CString& sLine, CClient* pClient = nullptr, CClient* pSkipClient = nullptr);
bool IsUserAttached() const;
void UserConnected(CClient* pClient);
+3 -3
View File
@@ -65,13 +65,13 @@ public:
static CString GetPass(const CString& sPrompt);
static bool GetInput(const CString& sPrompt, CString& sRet, const CString& sDefault = "", const CString& sHint = "");
static bool GetBoolInput(const CString& sPrompt, bool bDefault);
static bool GetBoolInput(const CString& sPrompt, bool *pbDefault = NULL);
static bool GetBoolInput(const CString& sPrompt, bool *pbDefault = nullptr);
static bool GetNumInput(const CString& sPrompt, unsigned int& uRet, unsigned int uMin = 0, unsigned int uMax = ~0, unsigned int uDefault = ~0);
static unsigned long long GetMillTime() {
struct timeval tv;
unsigned long long iTime = 0;
gettimeofday(&tv, NULL);
gettimeofday(&tv, nullptr);
iTime = (unsigned long long) tv.tv_sec * 1000;
iTime += ((unsigned long long) tv.tv_usec / 1000);
return iTime;
@@ -318,7 +318,7 @@ public:
Cleanup();
iterator it = m_mItems.find(Item);
if (it == m_mItems.end())
return NULL;
return nullptr;
return &it->second.second;
}
+4 -4
View File
@@ -54,7 +54,7 @@ public:
const CString& GetIP() const { return m_sIP; }
CUser* GetUser() const { return m_pUser; }
time_t GetLastActive() const { return m_tmLastActive; }
bool IsLoggedIn() const { return m_pUser != NULL; }
bool IsLoggedIn() const { return m_pUser != nullptr; }
bool IsAdmin() const;
void UpdateLastActive();
@@ -128,8 +128,8 @@ public:
bool OnLogin(const CString& sUser, const CString& sPass, bool bBasic) override;
void OnPageRequest(const CString& sURI) override;
EPageReqResult PrintTemplate(const CString& sPageName, CString& sPageRet, CModule* pModule = NULL);
EPageReqResult PrintStaticFile(const CString& sPath, CString& sPageRet, CModule* pModule = NULL);
EPageReqResult PrintTemplate(const CString& sPageName, CString& sPageRet, CModule* pModule = nullptr);
EPageReqResult PrintStaticFile(const CString& sPath, CString& sPageRet, CModule* pModule = nullptr);
CString FindTmpl(CModule* pModule, const CString& sName);
@@ -150,7 +150,7 @@ public:
protected:
using CHTTPSock::PrintErrorPage;
bool AddModLoop(const CString& sLoopName, CModule& Module, CTemplate *pTemplate = NULL);
bool AddModLoop(const CString& sLoopName, CModule& Module, CTemplate *pTemplate = nullptr);
VCString GetDirs(CModule* pModule, bool bIsTemplate);
void SetPaths(CModule* pModule, bool bIsTemplate = false);
void SetVars();
+1 -1
View File
@@ -564,7 +564,7 @@ public:
private:
protected:
unsigned char* strnchr(const unsigned char* src, unsigned char c, unsigned int iMaxBytes, unsigned char* pFill = NULL, unsigned int* piCount = NULL) const;
unsigned char* strnchr(const unsigned char* src, unsigned char c, unsigned int iMaxBytes, unsigned char* pFill = nullptr, unsigned int* piCount = nullptr) const;
};
/**
+1 -1
View File
@@ -74,7 +74,7 @@ public:
bool AddTrustedProxy(const CString& sHost);
bool RemTrustedProxy(const CString& sHost);
void Broadcast(const CString& sMessage, bool bAdminOnly = false,
CUser* pSkipUser = NULL, CClient* pSkipClient = NULL);
CUser* pSkipUser = nullptr, CClient* pSkipClient = nullptr);
void AddBytesRead(unsigned long long u) { m_uBytesRead += u; }
void AddBytesWritten(unsigned long long u) { m_uBytesWritten += u; }
unsigned long long BytesRead() const { return m_uBytesRead; }