Merge pull request #907 from jpnurmi/weffc++

Use member initialization lists [-Weffc++] (#270)
This commit is contained in:
Alexey Sokolov
2015-03-01 12:58:50 -08:00
8 changed files with 213 additions and 143 deletions

View File

@@ -89,26 +89,33 @@ protected:
class CClient : public CIRCSocket {
public:
CClient() : CIRCSocket() {
m_pUser = nullptr;
m_pNetwork = nullptr;
m_bGotPass = false;
m_bGotNick = false;
m_bGotUser = false;
m_bInCap = false;
m_bNamesx = false;
m_bUHNames = false;
m_bAway = false;
m_bServerTime = false;
m_bBatch = false;
m_bSelfMessage = false;
m_bPlaybackActive = false;
CClient()
: CIRCSocket(),
m_bGotPass(false),
m_bGotNick(false),
m_bGotUser(false),
m_bInCap(false),
m_bNamesx(false),
m_bUHNames(false),
m_bAway(false),
m_bServerTime(false),
m_bBatch(false),
m_bSelfMessage(false),
m_bPlaybackActive(false),
m_pUser(nullptr),
m_pNetwork(nullptr),
m_sNick("unknown-nick"),
m_sPass(""),
m_sUser(""),
m_sNetwork(""),
m_sIdentifier(""),
m_spAuth(),
m_ssAcceptedCaps()
{
EnableReadLine();
// RFC says a line can have 512 chars max, but we are
// a little more gentle ;)
SetMaxBufferThreshold(1024);
SetNick("unknown-nick");
}
virtual ~CClient();

View File

@@ -25,26 +25,37 @@ using std::set;
using std::vector;
using std::map;
CChan::CChan(const CString& sName, CIRCNetwork* pNetwork, bool bInConfig, CConfig *pConfig) {
m_sName = sName.Token(0);
m_sKey = sName.Token(1);
m_pNetwork = pNetwork;
CChan::CChan(const CString& sName, CIRCNetwork* pNetwork, bool bInConfig, CConfig *pConfig)
: m_bDetached(false),
m_bIsOn(false),
m_bAutoClearChanBuffer(pNetwork->GetUser()->AutoClearChanBuffer()),
m_bInConfig(bInConfig),
m_bDisabled(false),
m_bHasBufferCountSet(false),
m_bHasAutoClearChanBufferSet(false),
m_bStripControls(false),
m_bHasStripControlsSet(false),
m_sName(sName.Token(0)),
m_sKey(sName.Token(1)),
m_sTopic(""),
m_sTopicOwner(""),
m_ulTopicDate(0),
m_ulCreationDate(0),
m_pNetwork(pNetwork),
m_Nick(),
m_uJoinTries(0),
m_sDefaultModes(""),
m_msNicks(),
m_Buffer(),
m_bModeKnown(false),
m_musModes()
{
if (!m_pNetwork->IsChan(m_sName)) {
m_sName = "#" + m_sName;
}
m_bInConfig = bInConfig;
m_Nick.SetNetwork(m_pNetwork);
m_bDetached = false;
m_bDisabled = false;
m_bStripControls = false;
m_bHasBufferCountSet = false;
m_bHasAutoClearChanBufferSet = false;
m_bHasStripControlsSet = false;
m_Buffer.SetLineCount(m_pNetwork->GetUser()->GetBufferCount(), true);
m_bAutoClearChanBuffer = m_pNetwork->GetUser()->AutoClearChanBuffer();
Reset();
if (pConfig) {
CString sValue;

View File

@@ -28,23 +28,39 @@ using std::set;
#define MAX_POST_SIZE 1024 * 1024
CHTTPSock::CHTTPSock(CModule *pMod, const CString& sURIPrefix) : CSocket(pMod), m_sURIPrefix(sURIPrefix) {
CHTTPSock::CHTTPSock(CModule *pMod, const CString& sURIPrefix) : CHTTPSock(pMod, sURIPrefix, "", 0) {
Init();
}
CHTTPSock::CHTTPSock(CModule *pMod, const CString& sURIPrefix, const CString& sHostname, unsigned short uPort, int iTimeout) : CSocket(pMod, sHostname, uPort, iTimeout), m_sURIPrefix(sURIPrefix) {
CHTTPSock::CHTTPSock(CModule *pMod, const CString& sURIPrefix, const CString& sHostname, unsigned short uPort, int iTimeout)
: CSocket(pMod, sHostname, uPort, iTimeout),
m_bSentHeader(false),
m_bGotHeader(false),
m_bLoggedIn(false),
m_bPost(false),
m_bDone(false),
m_uPostLen(0),
m_sPostData(""),
m_sURI(""),
m_sUser(""),
m_sPass(""),
m_sContentType(""),
m_sDocRoot(""),
m_sForwardedIP(""),
m_msvsPOSTParams(),
m_msvsGETParams(),
m_msHeaders(),
m_bHTTP10Client(false),
m_sIfNoneMatch(""),
m_bAcceptGzip(false),
m_msRequestCookies(),
m_msResponseCookies(),
m_sURIPrefix(sURIPrefix)
{
Init();
}
void CHTTPSock::Init() {
m_bSentHeader = false;
m_bGotHeader = false;
m_bLoggedIn = false;
m_bPost = false;
m_bDone = false;
m_bHTTP10Client = false;
m_bAcceptGzip = false;
m_uPostLen = 0;
EnableReadLine();
SetMaxBufferThreshold(10240);
}

View File

@@ -106,26 +106,40 @@ bool CIRCNetwork::IsValidNetwork(const CString& sNetwork) {
return true;
}
CIRCNetwork::CIRCNetwork(CUser *pUser, const CString& sName) {
m_pUser = nullptr;
CIRCNetwork::CIRCNetwork(CUser *pUser, const CString& sName)
: m_sName(sName),
m_pUser(nullptr),
m_sNick(""),
m_sAltNick(""),
m_sIdent(""),
m_sRealName(""),
m_sBindHost(""),
m_sEncoding(""),
m_sQuitMsg(""),
m_ssTrustedFingerprints(),
m_pModules(new CModules),
m_vClients(),
m_pIRCSock(nullptr),
m_vChans(),
m_vQueries(),
m_sChanPrefixes(""),
m_bIRCConnectEnabled(true),
m_bStripControls(false),
m_sIRCServer(""),
m_vServers(),
m_uServerIdx(0),
m_IRCNick(),
m_bIRCAway(false),
m_fFloodRate(1),
m_uFloodBurst(4),
m_RawBuffer(),
m_MotdBuffer(),
m_NoticeBuffer(),
m_pPingTimer(nullptr),
m_pJoinTimer(nullptr),
m_uJoinDelay(0)
{
SetUser(pUser);
m_sName = sName;
m_pModules = new CModules;
m_pIRCSock = nullptr;
m_uServerIdx = 0;
m_sChanPrefixes = "";
m_bIRCAway = false;
m_sEncoding = "";
m_fFloodRate = 1;
m_uFloodBurst = 4;
m_uJoinDelay = 0;
SetStripControls(false);
m_RawBuffer.SetLineCount(100, true); // This should be more than enough raws, especially since we are buffering the MOTD separately
m_MotdBuffer.SetLineCount(200, true); // This should be more than enough motd lines
@@ -140,23 +154,7 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CString& sName) {
SetIRCConnectEnabled(true);
}
CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork &Network) {
m_pUser = nullptr;
SetUser(pUser);
m_pModules = new CModules;
m_pIRCSock = nullptr;
m_uServerIdx = 0;
m_sChanPrefixes = "";
m_bIRCAway = false;
m_sEncoding = "";
m_RawBuffer.SetLineCount(100, true); // This should be more than enough raws, especially since we are buffering the MOTD separately
m_MotdBuffer.SetLineCount(200, true); // This should be more than enough motd lines
m_NoticeBuffer.SetLineCount(250, true);
CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork &Network) : CIRCNetwork(pUser, "") {
Clone(Network);
}

View File

@@ -53,26 +53,37 @@ bool CIRCSock::IsFloodProtected(double fRate) {
return fRate > FLOOD_MINIMAL_RATE;
}
CIRCSock::CIRCSock(CIRCNetwork* pNetwork) : CIRCSocket() {
m_pNetwork = pNetwork;
m_bAuthed = false;
m_bNamesx = false;
m_bUHNames = false;
m_fFloodRate = m_pNetwork->GetFloodRate();
m_uFloodBurst = m_pNetwork->GetFloodBurst();
m_bFloodProtection = IsFloodProtected(m_fFloodRate);
m_iSendsAllowed = m_uFloodBurst;
CIRCSock::CIRCSock(CIRCNetwork* pNetwork)
: CIRCSocket(),
m_bAuthed(false),
m_bNamesx(false),
m_bUHNames(false),
m_sPerms("*!@%+"),
m_sPermModes("qaohv"),
m_scUserModes(),
m_mueChanModes(),
m_pNetwork(pNetwork),
m_Nick(),
m_sPass(""),
m_msChans(),
m_uMaxNickLen(9),
m_uCapPaused(0),
m_ssAcceptedCaps(),
m_ssPendingCaps(),
m_lastCTCP(0),
m_uNumCTCP(0),
m_mISupport(),
m_vsSendQueue(),
m_iSendsAllowed(pNetwork->GetFloodBurst()),
m_uFloodBurst(pNetwork->GetFloodBurst()),
m_fFloodRate(pNetwork->GetFloodRate()),
m_bFloodProtection(IsFloodProtected(pNetwork->GetFloodRate()))
{
EnableReadLine();
m_Nick.SetIdent(m_pNetwork->GetIdent());
m_Nick.SetHost(m_pNetwork->GetBindHost());
SetEncoding(m_pNetwork->GetEncoding());
m_uMaxNickLen = 9;
m_uCapPaused = 0;
m_lastCTCP = 0;
m_uNumCTCP = 0;
m_sPerms = "*!@%+";
m_sPermModes = "qaohv";
m_mueChanModes['b'] = ListArg;
m_mueChanModes['e'] = ListArg;
m_mueChanModes['I'] = ListArg;

View File

@@ -39,7 +39,7 @@ static CString ZNC_DefaultCipher() {
}
#endif
CZNCSock::CZNCSock(int timeout) : Csock(timeout) {
CZNCSock::CZNCSock(int timeout) : Csock(timeout), m_HostToVerifySSL(""), m_ssTrustedFingerprints(), m_ssCertVerificationErrors() {
#ifdef HAVE_LIBSSL
DisableSSLCompression();
FollowSSLCipherServerPreference();
@@ -52,7 +52,7 @@ CZNCSock::CZNCSock(int timeout) : Csock(timeout) {
#endif
}
CZNCSock::CZNCSock(const CString& sHost, u_short port, int timeout) : Csock(sHost, port, timeout) {
CZNCSock::CZNCSock(const CString& sHost, u_short port, int timeout) : Csock(sHost, port, timeout), m_HostToVerifySSL(""), m_ssTrustedFingerprints(), m_ssCertVerificationErrors() {
#ifdef HAVE_LIBSSL
DisableSSLCompression();
FollowSSLCipherServerPreference();
@@ -398,15 +398,13 @@ void CSockManager::FinishConnect(const CString& sHostname, u_short iPort, const
/////////////////// CSocket ///////////////////
CSocket::CSocket(CModule* pModule) : CZNCSock() {
m_pModule = pModule;
CSocket::CSocket(CModule* pModule) : CZNCSock(), m_pModule(pModule) {
if (m_pModule) m_pModule->AddSocket(this);
EnableReadLine();
SetMaxBufferThreshold(10240);
}
CSocket::CSocket(CModule* pModule, const CString& sHostname, unsigned short uPort, int iTimeout) : CZNCSock(sHostname, uPort, iTimeout) {
m_pModule = pModule;
CSocket::CSocket(CModule* pModule, const CString& sHostname, unsigned short uPort, int iTimeout) : CZNCSock(sHostname, uPort, iTimeout), m_pModule(pModule) {
if (m_pModule) m_pModule->AddSocket(this);
EnableReadLine();
SetMaxBufferThreshold(10240);

View File

@@ -50,36 +50,48 @@ protected:
};
CUser::CUser(const CString& sUserName)
: m_sUserName(sUserName), m_sCleanUserName(MakeCleanUserName(sUserName))
: m_sUserName(sUserName),
m_sCleanUserName(MakeCleanUserName(sUserName)),
m_sNick(m_sCleanUserName),
m_sAltNick(""),
m_sIdent(m_sCleanUserName),
m_sRealName(sUserName),
m_sBindHost(""),
m_sDCCBindHost(""),
m_sPass(""),
m_sPassSalt(""),
m_sStatusPrefix("*"),
m_sDefaultChanModes(""),
m_sClientEncoding(""),
m_sQuitMsg(""),
m_mssCTCPReplies(),
m_sTimestampFormat("[%H:%M:%S]"),
m_sTimezone(""),
m_eHashType(HASH_NONE),
m_sUserPath(CZNC::Get().GetUserPath() + "/" + sUserName),
m_bMultiClients(true),
m_bDenyLoadMod(false),
m_bAdmin(false),
m_bDenySetBindHost(false),
m_bAutoClearChanBuffer(true),
m_bAutoClearQueryBuffer(true),
m_bBeingDeleted(false),
m_bAppendTimestamp(false),
m_bPrependTimestamp(true),
m_pUserTimer(nullptr),
m_vIRCNetworks(),
m_vClients(),
m_ssAllowedHosts(),
m_uBufferCount(50),
m_uBytesRead(0),
m_uBytesWritten(0),
m_uMaxJoinTries(10),
m_uMaxNetworks(1),
m_uMaxQueryBuffers(50),
m_uMaxJoins(0),
m_sSkinName(""),
m_pModules(new CModules)
{
// set path that depends on the user name:
m_sUserPath = CZNC::Get().GetUserPath() + "/" + m_sUserName;
m_sTimezone = "";
m_sNick = m_sCleanUserName;
m_sIdent = m_sCleanUserName;
m_sRealName = sUserName;
m_uBytesRead = 0;
m_uBytesWritten = 0;
m_pModules = new CModules;
m_bMultiClients = true;
m_eHashType = HASH_NONE;
m_bDenyLoadMod = false;
m_bAdmin= false;
m_bDenySetBindHost= false;
m_sStatusPrefix = "*";
m_uBufferCount = 50;
m_uMaxJoinTries = 10;
m_bAutoClearChanBuffer = true;
m_bAutoClearQueryBuffer = true;
m_uMaxQueryBuffers = 50;
m_uMaxJoins = 0;
m_bBeingDeleted = false;
m_sTimestampFormat = "[%H:%M:%S]";
m_bAppendTimestamp = false;
m_bPrependTimestamp = true;
m_uMaxNetworks = 1;
m_sClientEncoding = "";
m_pUserTimer = new CUserTimer(this);
CZNC::Get().GetManager().AddCron(m_pUserTimer);
}

View File

@@ -37,28 +37,45 @@ static inline CString FormatBindError() {
return "Unable to bind [" + sError + "]";
}
CZNC::CZNC() {
CZNC::CZNC()
: m_TimeStarted(time(nullptr)),
m_eConfigState(ECONFIG_NOTHING),
m_vpListeners(),
m_msUsers(),
m_msDelUsers(),
m_Manager(),
m_sCurPath(""),
m_sZNCPath(""),
m_sConfigFile(""),
m_sSkinName(""),
m_sStatusPrefix(""),
m_sPidFile(""),
m_sSSLCertFile(""),
m_sSSLCiphers(""),
m_sSSLProtocols(""),
m_vsBindHosts(),
m_vsTrustedProxies(),
m_vsMotd(),
m_pLockFile(nullptr),
m_uiConnectDelay(5),
m_uiAnonIPLimit(10),
m_uiMaxBufferSize(500),
m_uDisabledSSLProtocols(Csock::EDP_SSL),
m_pModules(new CModules),
m_uBytesRead(0),
m_uBytesWritten(0),
m_lpConnectQueue(),
m_pConnectQueueTimer(nullptr),
m_uiConnectPaused(0),
m_sConnectThrottle(),
m_bProtectWebSessions(true),
m_bHideVersion(false)
{
if (!InitCsocket()) {
CUtils::PrintError("Could not initialize Csocket!");
exit(-1);
}
m_pModules = new CModules();
m_uiConnectDelay = 5;
m_uiAnonIPLimit = 10;
m_uBytesRead = 0;
m_uBytesWritten = 0;
m_uiMaxBufferSize = 500;
m_pConnectQueueTimer = nullptr;
m_uiConnectPaused = 0;
m_eConfigState = ECONFIG_NOTHING;
m_TimeStarted = time(nullptr);
m_sConnectThrottle.SetTTL(30000);
m_pLockFile = nullptr;
m_bProtectWebSessions = true;
m_bHideVersion = false;
m_uDisabledSSLProtocols = Csock::EDP_SSL;
m_sSSLProtocols = "";
}
CZNC::~CZNC() {