From: Maxim Mamontov Date: Sat, 21 Jan 2017 18:19:06 +0000 (+0200) Subject: Various fixes of issues reported by static analyzers. X-Git-Tag: 2.409~31 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/afcbfd1a09e22ff4839ba5db42047c96f355506c Various fixes of issues reported by static analyzers. --- diff --git a/include/stg/admin_conf.h b/include/stg/admin_conf.h index f88ab0c8..a2639d36 100644 --- a/include/stg/admin_conf.h +++ b/include/stg/admin_conf.h @@ -29,7 +29,7 @@ struct PRIV serviceChg(0), corpChg(0) {} - PRIV(uint32_t p) + explicit PRIV(uint32_t p) : userStat((p & 0x00000003) >> 0x00), userConf((p & 0x0000000C) >> 0x02), userCash((p & 0x00000030) >> 0x04), @@ -62,11 +62,6 @@ struct ADMIN_CONF login(), password("* NO PASSWORD *") {} - ADMIN_CONF(const ADMIN_CONF & rvalue) - : priv(rvalue.priv), - login(rvalue.login), - password(rvalue.password) - {} ADMIN_CONF(const PRIV & pr, const std::string & l, const std::string & p) : priv(pr), login(l), @@ -81,18 +76,6 @@ struct ADMIN_CONF_RES { ADMIN_CONF_RES() {} - ADMIN_CONF_RES(const ADMIN_CONF_RES & rhs) - : priv(rhs.priv), - login(rhs.login), - password(rhs.password) - {} - ADMIN_CONF_RES & operator=(const ADMIN_CONF_RES & rhs) - { - priv = rhs.priv; - login = rhs.login; - password = rhs.password; - return *this; - } RESETABLE priv; RESETABLE login; RESETABLE password; diff --git a/include/stg/corp_conf.h b/include/stg/corp_conf.h index d6cc2ebb..3810516d 100644 --- a/include/stg/corp_conf.h +++ b/include/stg/corp_conf.h @@ -6,7 +6,7 @@ struct CORP_CONF { CORP_CONF() : name(), cash(0) {} -CORP_CONF(const std::string & n) : name(n), cash(0) {} +explicit CORP_CONF(const std::string & n) : name(n), cash(0) {} CORP_CONF(const std::string & n, double c) : name(n), cash(c) {} std::string name; diff --git a/include/stg/locker.h b/include/stg/locker.h index fe1014d7..2a395f37 100644 --- a/include/stg/locker.h +++ b/include/stg/locker.h @@ -34,7 +34,7 @@ class STG_LOCKER { public: - STG_LOCKER(pthread_mutex_t * m) + explicit STG_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); diff --git a/include/stg/plugin_creator.h b/include/stg/plugin_creator.h index 755c2068..e1531e12 100644 --- a/include/stg/plugin_creator.h +++ b/include/stg/plugin_creator.h @@ -1,20 +1,19 @@ #ifndef __PLUGIN_CREATOR_H__ #define __PLUGIN_CREATOR_H__ +#include "noncopyable.h" + template -class PLUGIN_CREATOR +class PLUGIN_CREATOR : private NONCOPYABLE { public: PLUGIN_CREATOR() : plugin(new T()) {} - ~PLUGIN_CREATOR() { delete plugin; } + //~PLUGIN_CREATOR() { delete plugin; } T * GetPlugin() { return plugin; } private: T * plugin; - - PLUGIN_CREATOR(const PLUGIN_CREATOR & rvalue); - PLUGIN_CREATOR & operator=(const PLUGIN_CREATOR & rvalue); }; #endif diff --git a/include/stg/resetable.h b/include/stg/resetable.h index a451b357..e7914efd 100644 --- a/include/stg/resetable.h +++ b/include/stg/resetable.h @@ -16,19 +16,7 @@ public: typedef T value_type; RESETABLE() : value(), is_set(false) {} - RESETABLE(const T & v) : value(v), is_set(true) {} - - RESETABLE(const RESETABLE & rvalue) - : value(rvalue.value), - is_set(rvalue.is_set) - {} - - RESETABLE & operator=(const RESETABLE & rhs) - { - value = rhs.value; - is_set = rhs.is_set; - return *this; - } + explicit RESETABLE(const T & v) : value(v), is_set(true) {} RESETABLE & operator=(const T & rhs) { diff --git a/include/stg/service_conf.h b/include/stg/service_conf.h index 84f052a5..b6c24490 100644 --- a/include/stg/service_conf.h +++ b/include/stg/service_conf.h @@ -31,7 +31,7 @@ struct SERVICE_CONF SERVICE_CONF() : name(), comment(), cost(0), payDay(0) {} -SERVICE_CONF(const std::string & n) +explicit SERVICE_CONF(const std::string & n) : name(n), comment(), cost(0), payDay(0) {} SERVICE_CONF(const std::string & n, double c) @@ -58,7 +58,7 @@ SERVICE_CONF_RES() cost(), payDay() {} -SERVICE_CONF_RES(const SERVICE_CONF & rhs) +explicit SERVICE_CONF_RES(const SERVICE_CONF & rhs) : name(rhs.name), comment(rhs.comment), cost(rhs.cost), payDay(rhs.payDay) {} diff --git a/include/stg/tariff_conf.h b/include/stg/tariff_conf.h index 79ade2eb..f705d0a0 100644 --- a/include/stg/tariff_conf.h +++ b/include/stg/tariff_conf.h @@ -162,7 +162,7 @@ struct TARIFF_CONF changePolicyTimeout(0) {} - TARIFF_CONF(const std::string & n) + explicit TARIFF_CONF(const std::string & n) : fee(0), free(0), traffType(TARIFF::TRAFF_UP_DOWN), @@ -234,22 +234,10 @@ struct TARIFF_DATA dirPrice(DIR_NUM) {} - TARIFF_DATA(const std::string & name) + explicit TARIFF_DATA(const std::string & name) : tariffConf(name), dirPrice(DIR_NUM) {} - - TARIFF_DATA(const TARIFF_DATA & td) - : tariffConf(td.tariffConf), - dirPrice(td.dirPrice) - {} - - TARIFF_DATA & operator=(const TARIFF_DATA & td) - { - tariffConf = td.tariffConf; - dirPrice = td.dirPrice; - return *this; - } }; //----------------------------------------------------------------------------- struct TARIFF_DATA_RES diff --git a/include/stg/user_property.h b/include/stg/user_property.h index f024f457..4a26b211 100644 --- a/include/stg/user_property.h +++ b/include/stg/user_property.h @@ -39,7 +39,7 @@ typedef std::map REGISTRY; template class USER_PROPERTY : public USER_PROPERTY_BASE { public: - USER_PROPERTY(varT & val); + explicit USER_PROPERTY(varT & val); virtual ~USER_PROPERTY(); void Set(const varT & rvalue); @@ -131,7 +131,7 @@ private: REGISTRY properties; public: - USER_PROPERTIES(const SETTINGS& s); + explicit USER_PROPERTIES(const SETTINGS& s); USER_STAT & Stat() { return stat; } USER_CONF & Conf() { return conf; } diff --git a/include/stg/user_traff.h b/include/stg/user_traff.h index eec46276..d820588e 100644 --- a/include/stg/user_traff.h +++ b/include/stg/user_traff.h @@ -45,8 +45,6 @@ public: typedef ContainerType::size_type IndexType; DIR_TRAFF() : traff(DIR_NUM) {} - DIR_TRAFF(const DIR_TRAFF & ts) : traff(ts.traff) {} - DIR_TRAFF & operator=(const DIR_TRAFF & ts) { traff = ts.traff; return *this; } const uint64_t & operator[](IndexType idx) const { return traff[idx]; } uint64_t & operator[](IndexType idx) { return traff[idx]; } IndexType size() const { return traff.size(); } @@ -85,12 +83,18 @@ public: typedef ContainerType::size_type IndexType; DIR_TRAFF_RES() : traff(DIR_NUM) {} - DIR_TRAFF_RES(const DIR_TRAFF & ts) + explicit DIR_TRAFF_RES(const DIR_TRAFF & ts) : traff(ts.size()) { for (IndexType i = 0; i < ts.size(); ++i) traff[i] = ts[i]; } + DIR_TRAFF_RES & operator=(const DIR_TRAFF & ts) + { + for (IndexType i = 0; i < ts.size(); ++i) + traff[i] = ts[i]; + return *this; + } const ValueType & operator[](IndexType idx) const { return traff[idx]; } ValueType & operator[](IndexType idx) { return traff[idx]; } DIR_TRAFF GetData() const diff --git a/include/stg/utime.h b/include/stg/utime.h index fe6b3f69..853b3db1 100644 --- a/include/stg/utime.h +++ b/include/stg/utime.h @@ -46,7 +46,7 @@ struct UTIME: public timeval tv_usec = 0; } - UTIME(time_t t) + explicit UTIME(time_t t) { tv_sec = t; tv_usec = 0; diff --git a/projects/rscriptd/listener.h b/projects/rscriptd/listener.h index c6fb143a..22b029b6 100644 --- a/projects/rscriptd/listener.h +++ b/projects/rscriptd/listener.h @@ -56,7 +56,7 @@ struct AliveData : public UserData class IsNotTimedOut : public std::unary_function { public: - IsNotTimedOut(double to) : timeout(to), now(time(NULL)) {} + explicit IsNotTimedOut(double to) : timeout(to), now(time(NULL)) {} bool operator()(const AliveData & data) const { return difftime(now, data.lastAlive) < timeout; @@ -133,7 +133,7 @@ private: class DisconnectUser : public std::unary_function { public: - DisconnectUser(LISTENER & l) : listener(l) {}; + explicit DisconnectUser(LISTENER & l) : listener(l) {}; void operator()(const UserData & data) { listener.Disconnect(data); diff --git a/projects/rscriptd/pidfile.h b/projects/rscriptd/pidfile.h index a8a7bb30..82ff0038 100644 --- a/projects/rscriptd/pidfile.h +++ b/projects/rscriptd/pidfile.h @@ -35,7 +35,7 @@ class PIDFile { public: - PIDFile(const std::string & fn); + explicit PIDFile(const std::string & fn); ~PIDFile(); private: std::string fileName; diff --git a/projects/sgauth/web.cpp b/projects/sgauth/web.cpp index 01660b61..8c23482b 100644 --- a/projects/sgauth/web.cpp +++ b/projects/sgauth/web.cpp @@ -358,7 +358,6 @@ res = send(outerSocket, str, strlen(str), 0); sprintf(str," %s\n", gettext("Session Download")); res = send(outerSocket, str, strlen(str), 0); -rowNum = 0; for (j = 0; j < DIR_NUM; j++) { if (dirName[j][0] == 0) diff --git a/projects/sgconf/common_sg.cpp b/projects/sgconf/common_sg.cpp index 9c1b7283..86214a3d 100644 --- a/projects/sgconf/common_sg.cpp +++ b/projects/sgconf/common_sg.cpp @@ -213,13 +213,6 @@ return usr; void ConvertKOI8(const string & src, string * dst, int encType) { iconv_t cd; -char * ob = new char[src.size() * 2 + 1]; -char * ib = new char[src.size() + 1]; - -strcpy(ib, src.c_str()); - -char * outbuf = ob; -char * inbuf = ib; setlocale(LC_ALL, ""); @@ -239,11 +232,6 @@ else size_t nconv = 1; -size_t insize = strlen(ib); -size_t outsize = insize * 2 + 1; - -insize = src.size(); - cd = iconv_open(charsetT, charsetF); if (cd == (iconv_t) -1) { @@ -259,6 +247,19 @@ if (cd == (iconv_t) -1) exit(ICONV_ERR_CODE); } +char * ob = new char[src.size() * 2 + 1]; +char * ib = new char[src.size() + 1]; + +strcpy(ib, src.c_str()); + +char * outbuf = ob; +char * inbuf = ib; + +size_t insize = strlen(ib); +size_t outsize = insize * 2 + 1; + +insize = src.size(); + #if defined(CONST_ICONV) nconv = iconv(cd, (const char **)&inbuf, &insize, &outbuf, &outsize); #else diff --git a/projects/sgconf/main.cpp b/projects/sgconf/main.cpp index b107ee95..3eaffb9f 100644 --- a/projects/sgconf/main.cpp +++ b/projects/sgconf/main.cpp @@ -332,13 +332,6 @@ return stg_timegm(&brokenTime); void ParseAnyString(const char * c, string * msg, const char * enc) { iconv_t cd; -char * ob = new char[strlen(c) + 1]; -char * ib = new char[strlen(c) + 1]; - -strcpy(ib, c); - -char * outbuf = ob; -char * inbuf = ib; setlocale(LC_ALL, ""); @@ -349,11 +342,6 @@ const char * charsetT = enc; size_t nconv = 1; -size_t insize = strlen(ib); -size_t outsize = strlen(ib); - -insize = strlen(c); - cd = iconv_open(charsetT, charsetF); if (cd == (iconv_t) -1) { @@ -369,6 +357,17 @@ if (cd == (iconv_t) -1) exit(ICONV_ERR_CODE); } +char * ob = new char[strlen(c) + 1]; +char * ib = new char[strlen(c) + 1]; + +strcpy(ib, c); + +char * outbuf = ob; +char * inbuf = ib; + +size_t insize = strlen(c); +size_t outsize = strlen(ib); + #if defined(CONST_ICONV) nconv = iconv (cd, (const char**)&inbuf, &insize, &outbuf, &outsize); #else diff --git a/projects/sgconv/settings_impl.h b/projects/sgconv/settings_impl.h index 3dfb9596..0a0b5d1a 100644 --- a/projects/sgconv/settings_impl.h +++ b/projects/sgconv/settings_impl.h @@ -39,7 +39,7 @@ class DOTCONFDocumentNode; class SETTINGS_IMPL { public: SETTINGS_IMPL() : confFile("./sgconv.conf") {} - SETTINGS_IMPL(const std::string & cf) : confFile(cf) {} + explicit SETTINGS_IMPL(const std::string & cf) : confFile(cf) {} ~SETTINGS_IMPL() {} int ReadSettings(); diff --git a/projects/stargazer/admin_impl.cpp b/projects/stargazer/admin_impl.cpp index 3d2c4895..400fe5c4 100644 --- a/projects/stargazer/admin_impl.cpp +++ b/projects/stargazer/admin_impl.cpp @@ -29,22 +29,21 @@ */ #include "admin_impl.h" + #include "stg/common.h" //----------------------------------------------------------------------------- ADMIN_IMPL::ADMIN_IMPL() : ADMIN(), conf(), - ip(0), - WriteServLog(GetStgLogger()) + ip(0) { } //----------------------------------------------------------------------------- ADMIN_IMPL::ADMIN_IMPL(const ADMIN_CONF & ac) : ADMIN(), conf(ac), - ip(0), - WriteServLog(GetStgLogger()) + ip(0) { } //----------------------------------------------------------------------------- @@ -53,8 +52,7 @@ ADMIN_IMPL::ADMIN_IMPL(const PRIV & priv, const std::string & password) : ADMIN(), conf(priv, login, password), - ip(0), - WriteServLog(GetStgLogger()) + ip(0) { } //----------------------------------------------------------------------------- diff --git a/projects/stargazer/admin_impl.h b/projects/stargazer/admin_impl.h index 9a2b9781..88f38eb4 100644 --- a/projects/stargazer/admin_impl.h +++ b/projects/stargazer/admin_impl.h @@ -31,17 +31,16 @@ #ifndef ADMIN_IMPL_H #define ADMIN_IMPL_H -#include - #include "stg/admin.h" #include "stg/os_int.h" #include "stg/admin_conf.h" -#include "stg/logger.h" + +#include class ADMIN_IMPL : public ADMIN { public: ADMIN_IMPL(); - ADMIN_IMPL(const ADMIN_CONF & ac); + explicit ADMIN_IMPL(const ADMIN_CONF & ac); ADMIN_IMPL(const PRIV & priv, const std::string & login, const std::string & password); @@ -68,7 +67,6 @@ public: private: ADMIN_CONF conf; uint32_t ip; - STG_LOGGER & WriteServLog; }; #endif diff --git a/projects/stargazer/admins_impl.cpp b/projects/stargazer/admins_impl.cpp index fb28b6e6..8f2760ce 100644 --- a/projects/stargazer/admins_impl.cpp +++ b/projects/stargazer/admins_impl.cpp @@ -28,19 +28,19 @@ $Author: faust $ */ -#include -#include -#include - #include "stg/common.h" #include "admins_impl.h" #include "admin_impl.h" +#include +#include +#include + //----------------------------------------------------------------------------- ADMINS_IMPL::ADMINS_IMPL(STORE * st) : ADMINS(), - stg(0xFFFF, "@stargazer", ""), - noAdmin(0xFFFF, "NO-ADMIN", ""), + stg(PRIV(0xFFFF), "@stargazer", ""), + noAdmin(PRIV(0xFFFF), "NO-ADMIN", ""), data(), store(st), WriteServLog(GetStgLogger()), @@ -66,7 +66,7 @@ if (!priv->adminChg) return -1; } -ADMIN_IMPL adm(0, login, ""); +ADMIN_IMPL adm(PRIV(0), login, ""); admin_iter ai(find(data.begin(), data.end(), adm)); if (ai != data.end()) @@ -95,7 +95,6 @@ return -1; int ADMINS_IMPL::Del(const std::string & login, const ADMIN * admin) { STG_LOCKER lock(&mutex); -ADMIN_IMPL adm(0, login, ""); const PRIV * priv = admin->GetPriv(); if (!priv->adminChg) @@ -106,7 +105,7 @@ if (!priv->adminChg) return -1; } -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, ""))); if (ai == data.end()) { @@ -121,7 +120,7 @@ while (si != searchDescriptors.end()) { if (si->second == ai) (si->second)++; - si++; + ++si; } data.remove(*ai); @@ -150,8 +149,7 @@ if (!priv->adminChg) return -1; } -ADMIN_IMPL adm(0, ac.login, ""); -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), ac.login, ""))); if (ai == data.end()) { @@ -186,7 +184,7 @@ if (store->GetAdminsList(&adminsList) < 0) for (unsigned int i = 0; i < adminsList.size(); i++) { - ADMIN_CONF ac(0, adminsList[i], ""); + ADMIN_CONF ac(PRIV(0), adminsList[i], ""); if (store->RestoreAdmin(&ac, adminsList[i])) { @@ -211,8 +209,7 @@ if (data.empty()) return false; } -ADMIN_IMPL adm(0, l, ""); -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), l, ""))); if (ai != data.end()) { @@ -232,8 +229,7 @@ if (data.empty()) return true; } -ADMIN_IMPL adm(0, login, ""); -const_admin_iter ai(find(data.begin(), data.end(), adm)); +const_admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, ""))); if (ai != data.end()) return true; @@ -250,8 +246,7 @@ if (data.empty()) return true; } -ADMIN_IMPL adm(0, login, ""); -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, ""))); if (ai == data.end()) { diff --git a/projects/stargazer/admins_impl.h b/projects/stargazer/admins_impl.h index 7434c445..03aa4ece 100644 --- a/projects/stargazer/admins_impl.h +++ b/projects/stargazer/admins_impl.h @@ -31,11 +31,7 @@ #ifndef ADMINS_IMPL_H #define ADMINS_IMPL_H -#include - -#include -#include -#include +#include "admin_impl.h" #include "stg/admins.h" #include "stg/admin.h" @@ -43,11 +39,16 @@ #include "stg/store.h" #include "stg/noncopyable.h" #include "stg/logger.h" -#include "admin_impl.h" + +#include +#include +#include + +#include class ADMINS_IMPL : private NONCOPYABLE, public ADMINS { public: - ADMINS_IMPL(STORE * st); + explicit ADMINS_IMPL(STORE * st); virtual ~ADMINS_IMPL() {} int Add(const std::string & login, const ADMIN * admin); diff --git a/projects/stargazer/corps_impl.cpp b/projects/stargazer/corps_impl.cpp index 4109bb28..098acaca 100644 --- a/projects/stargazer/corps_impl.cpp +++ b/projects/stargazer/corps_impl.cpp @@ -18,13 +18,14 @@ * Author : Maxim Mamontov */ -#include -#include -#include +#include "corps_impl.h" #include "stg/admin.h" #include "stg/common.h" -#include "corps_impl.h" + +#include +#include +#include //----------------------------------------------------------------------------- CORPORATIONS_IMPL::CORPORATIONS_IMPL(STORE * st) @@ -107,7 +108,7 @@ while (csi != searchDescriptors.end()) { if (csi->second == si) (csi->second)++; - csi++; + ++csi; } data.remove(*si); diff --git a/projects/stargazer/corps_impl.h b/projects/stargazer/corps_impl.h index 7bde401b..3765c5c1 100644 --- a/projects/stargazer/corps_impl.h +++ b/projects/stargazer/corps_impl.h @@ -21,12 +21,6 @@ #ifndef CORPORATIONS_IMPL_H #define CORPORATIONS_IMPL_H -#include - -#include -#include -#include - #include "stg/corporations.h" #include "stg/corp_conf.h" #include "stg/locker.h" @@ -34,11 +28,17 @@ #include "stg/noncopyable.h" #include "stg/logger.h" +#include +#include +#include + +#include + class ADMIN; class CORPORATIONS_IMPL : private NONCOPYABLE, public CORPORATIONS { public: - CORPORATIONS_IMPL(STORE * st); + explicit CORPORATIONS_IMPL(STORE * st); virtual ~CORPORATIONS_IMPL() {} int Add(const CORP_CONF & corp, const ADMIN * admin); diff --git a/projects/stargazer/pidfile.h b/projects/stargazer/pidfile.h index 47fbefd9..2600f7fe 100644 --- a/projects/stargazer/pidfile.h +++ b/projects/stargazer/pidfile.h @@ -35,7 +35,7 @@ class PIDFile { public: - PIDFile(const std::string & fn); + explicit PIDFile(const std::string & fn); ~PIDFile(); private: std::string fileName; diff --git a/projects/stargazer/plugin_runner.cpp b/projects/stargazer/plugin_runner.cpp index e57a421e..e43271c0 100644 --- a/projects/stargazer/plugin_runner.cpp +++ b/projects/stargazer/plugin_runner.cpp @@ -48,6 +48,7 @@ PLUGIN_RUNNER::PLUGIN_RUNNER(const std::string & fileName, //----------------------------------------------------------------------------- PLUGIN_RUNNER::~PLUGIN_RUNNER() { +delete &m_plugin; if (dlclose(libHandle)) { errorStr = "Failed to unload plugin '" + pluginFileName + "': " + dlerror(); diff --git a/projects/stargazer/plugin_runner.h b/projects/stargazer/plugin_runner.h index 2d0c22c4..a30b6940 100644 --- a/projects/stargazer/plugin_runner.h +++ b/projects/stargazer/plugin_runner.h @@ -42,7 +42,7 @@ class STORE; class PLUGIN_RUNNER { public: struct Error : public std::runtime_error { - Error(const std::string & msg) : runtime_error(msg) {} + explicit Error(const std::string & msg) : runtime_error(msg) {} }; PLUGIN_RUNNER(const std::string & pluginFileName, diff --git a/projects/stargazer/plugins/authorization/ao/ao.cpp b/projects/stargazer/plugins/authorization/ao/ao.cpp index 5acea091..853df2a4 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.cpp +++ b/projects/stargazer/plugins/authorization/ao/ao.cpp @@ -56,7 +56,7 @@ template class IS_CONTAINS_USER: public std::binary_function { public: - bool operator()(varType notifier, USER_PTR user) const + bool operator()(const varType& notifier, USER_PTR user) const { return notifier.GetUser() == user; } diff --git a/projects/stargazer/plugins/authorization/ao/ao.h b/projects/stargazer/plugins/authorization/ao/ao.h index 9ed7ffcf..bf1cbe6b 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.h +++ b/projects/stargazer/plugins/authorization/ao/ao.h @@ -126,7 +126,7 @@ private: class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {} + explicit ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {} virtual ~ADD_USER_NONIFIER() {} void Notify(const USER_PTR & user) { auth.AddUser(user); } @@ -139,7 +139,7 @@ private: class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {} + explicit DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {} virtual ~DEL_USER_NONIFIER() {} void Notify(const USER_PTR & user) { auth.DelUser(user); } diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp index 99e0a091..de30e7d2 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp @@ -480,7 +480,7 @@ while (ia->nonstop) { touchTime = stgTime; std::string monFile = ia->stgSettings->GetMonitorDir() + "/inetaccess_r"; - TouchFile(monFile.c_str()); + TouchFile(monFile); } } @@ -508,7 +508,7 @@ while (ia->nonstop) // TODO change counter to timer and MONITOR_TIME_DELAY_SEC if (++a % (50 * 60) == 0 && ia->stgSettings->GetMonitoring()) { - TouchFile(monFile.c_str()); + TouchFile(monFile); } } @@ -706,7 +706,7 @@ while (it != ip2user.end()) && (currTime - it->second.phase.GetTime()) > iaSettings.GetUserDelay()) { if (iaSettings.LogProtocolErrors()) - logger("User '%s'. Protocol version: %d. Phase 2: connect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay()); + logger("User '%s'. Protocol version: %d. Phase 2: connect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay().GetSec()); it->second.phase.SetPhase1(); printfd(__FILE__, "Phase changed from 2 to 1. Reason: timeout\n"); ip2user.erase(it++); @@ -750,7 +750,7 @@ while (it != ip2user.end()) if ((currTime - it->second.phase.GetTime()) > iaSettings.GetUserTimeout()) { if (iaSettings.LogProtocolErrors()) - logger("User '%s'. Protocol version: %d. Phase 3: alive timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserTimeout()); + logger("User '%s'. Protocol version: %d. Phase 3: alive timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserTimeout().GetSec()); users->Unauthorize(it->second.user->GetLogin(), this); ip2user.erase(it++); continue; @@ -761,7 +761,7 @@ while (it != ip2user.end()) && ((currTime - it->second.phase.GetTime()) > iaSettings.GetUserDelay())) { if (iaSettings.LogProtocolErrors()) - logger("User '%s'. Protocol version: %d. Phase 4: disconnect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay()); + logger("User '%s'. Protocol version: %d. Phase 4: disconnect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay().GetSec()); it->second.phase.SetPhase3(); printfd(__FILE__, "Phase changed from 4 to 3. Reason: timeout\n"); } @@ -1411,8 +1411,8 @@ for (int j = 0; j < DIR_NUM; j++) iaUser->rnd = static_cast(random()); connSynAck6.rnd = iaUser->rnd; -connSynAck6.userTimeOut = iaSettings.GetUserTimeout(); -connSynAck6.aliveDelay = iaSettings.GetUserDelay(); +connSynAck6.userTimeOut = iaSettings.GetUserTimeout().GetSec(); +connSynAck6.aliveDelay = iaSettings.GetUserDelay().GetSec(); #ifdef ARCH_BE SwapBytes(connSynAck6.len); @@ -1453,8 +1453,8 @@ for (int j = 0; j < DIR_NUM; j++) iaUser->rnd = static_cast(random()); connSynAck8.rnd = iaUser->rnd; -connSynAck8.userTimeOut = iaSettings.GetUserTimeout(); -connSynAck8.aliveDelay = iaSettings.GetUserDelay(); +connSynAck8.userTimeOut = iaSettings.GetUserTimeout().GetSec(); +connSynAck8.aliveDelay = iaSettings.GetUserDelay().GetSec(); #ifdef ARCH_BE SwapBytes(connSynAck8.len); diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h index 2b527076..fb851f52 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h @@ -27,17 +27,6 @@ #ifndef INETACCESS_H #define INETACCESS_H -#include -#include - -#include -#include -#include -#include -#include -#include -#include - #include "stg/os_int.h" #include "stg/auth.h" #include "stg/store.h" @@ -51,6 +40,17 @@ #include "stg/utime.h" #include "stg/logger.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include + #define IA_PROTO_VER (6) //#define IA_DEBUG (1) @@ -204,8 +204,8 @@ public: virtual ~AUTH_IA_SETTINGS() {} const std::string & GetStrError() const { return errorStr; } int ParseSettings(const MODULE_SETTINGS & s); - int GetUserDelay() const { return userDelay; } - int GetUserTimeout() const { return userTimeout; } + UTIME GetUserDelay() const { return UTIME(userDelay); } + UTIME GetUserTimeout() const { return UTIME(userTimeout); } uint16_t GetUserPort() const { return port; } FREEMB GetFreeMbShowType() const { return freeMbShowType; } bool LogProtocolErrors() const { return logProtocolErrors; } @@ -223,7 +223,7 @@ class AUTH_IA; //----------------------------------------------------------------------------- class DEL_USER_NOTIFIER: public NOTIFIER_BASE { public: - DEL_USER_NOTIFIER(AUTH_IA & a) : auth(a) {} + explicit DEL_USER_NOTIFIER(AUTH_IA & a) : auth(a) {} virtual ~DEL_USER_NOTIFIER() {} void Notify(const USER_PTR & user); @@ -369,7 +369,7 @@ private: //----------------------------------------------------------------------------- class UnauthorizeUser : std::unary_function &, void> { public: - UnauthorizeUser(AUTH_IA * a) : auth(a) {} + explicit UnauthorizeUser(AUTH_IA * a) : auth(a) {} UnauthorizeUser(const UnauthorizeUser & rvalue) : auth(rvalue.auth) {} void operator()(const std::pair & p) { diff --git a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h index cb72bbf7..f781b9be 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.h @@ -44,7 +44,7 @@ private: class METHOD_LOGIN : public xmlrpc_c::method { public: - METHOD_LOGIN(RPC_CONFIG * c) + explicit METHOD_LOGIN(RPC_CONFIG * c) : config(c) { } @@ -62,7 +62,7 @@ private: class METHOD_LOGOUT : public xmlrpc_c::method { public: - METHOD_LOGOUT(RPC_CONFIG * c) + explicit METHOD_LOGOUT(RPC_CONFIG * c) : config(c) { } diff --git a/projects/stargazer/plugins/configuration/rpcconfig/tariff_helper.h b/projects/stargazer/plugins/configuration/rpcconfig/tariff_helper.h index 955f810e..a30b992a 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/tariff_helper.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/tariff_helper.h @@ -7,7 +7,7 @@ class TARIFF_HELPER { public: - TARIFF_HELPER(TARIFF_DATA & td) + explicit TARIFF_HELPER(TARIFF_DATA & td) : data(td) {} diff --git a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp index 567c537a..020c1365 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp @@ -65,9 +65,16 @@ CONFIGPROTO::CONFIGPROTO(PLUGIN_LOGGER & l) CONFIGPROTO::~CONFIGPROTO() { + { std::deque::iterator it; for (it = m_conns.begin(); it != m_conns.end(); ++it) delete *it; + } + { + BASE_PARSER::REGISTRY::iterator it; + for (it = m_registry.begin(); it != m_registry.end(); ++it) + delete it->second; + } } int CONFIGPROTO::Prepare() diff --git a/projects/stargazer/plugins/configuration/sgconfig/configproto.h b/projects/stargazer/plugins/configuration/sgconfig/configproto.h index 2119bc67..f8073575 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.h +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.h @@ -50,7 +50,7 @@ class Conn; class CONFIGPROTO { public: - CONFIGPROTO(PLUGIN_LOGGER & l); + explicit CONFIGPROTO(PLUGIN_LOGGER & l); ~CONFIGPROTO(); void SetPort(uint16_t port) { m_port = port; } diff --git a/projects/stargazer/plugins/configuration/sgconfig/conn.cpp b/projects/stargazer/plugins/configuration/sgconfig/conn.cpp index c792125e..71de7356 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/conn.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/conn.cpp @@ -81,6 +81,9 @@ Conn::~Conn() close(m_sock); XML_ParserFree(m_xmlParser); + + delete m_stream; + delete m_parser; } bool Conn::Read() @@ -283,6 +286,8 @@ bool Conn::WriteResponse() answer = m_parser->GetAnswer(); else answer = ""; + delete m_parser; + m_parser = NULL; printfd(__FILE__, "Writing %d bytes of answer.\n", answer.length()); stream.Put(answer.c_str(), answer.length() + 1 /* including \0 */, true /* final */); return stream.IsOk(); diff --git a/projects/stargazer/plugins/configuration/sgconfig/conn.h b/projects/stargazer/plugins/configuration/sgconfig/conn.h index c67c972e..ed2e64d1 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/conn.h +++ b/projects/stargazer/plugins/configuration/sgconfig/conn.h @@ -53,7 +53,7 @@ class Conn public: struct Error : public std::runtime_error { - Error(const std::string& message) : runtime_error(message.c_str()) {} + explicit Error(const std::string& message) : runtime_error(message.c_str()) {} }; Conn(const BASE_PARSER::REGISTRY & registry, diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser.h b/projects/stargazer/plugins/configuration/sgconfig/parser.h index af77158d..8bddc517 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser.h @@ -31,6 +31,7 @@ class BASE_PARSER public: struct FACTORY { + virtual ~FACTORY() {} virtual BASE_PARSER * create(const ADMIN & admin) = 0; }; typedef std::map REGISTRY; diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_admins.h b/projects/stargazer/plugins/configuration/sgconfig/parser_admins.h index 3b99e642..70ae0274 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_admins.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_admins.h @@ -43,7 +43,7 @@ class GET_ADMINS: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const ADMINS & admins) : m_admins(admins) {} + explicit FACTORY(const ADMINS & admins) : m_admins(admins) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_ADMINS(admin, m_admins); } static void Register(REGISTRY & registry, const ADMINS & admins) { registry[ToLower(tag)] = new FACTORY(admins); } @@ -68,7 +68,7 @@ class ADD_ADMIN: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(ADMINS & admins) : m_admins(admins) {} + explicit FACTORY(ADMINS & admins) : m_admins(admins) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_ADMIN(admin, m_admins); } static void Register(REGISTRY & registry, ADMINS & admins) { registry[ToLower(tag)] = new FACTORY(admins); } @@ -95,7 +95,7 @@ class DEL_ADMIN: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(ADMINS & admins) : m_admins(admins) {} + explicit FACTORY(ADMINS & admins) : m_admins(admins) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_ADMIN(admin, m_admins); } static void Register(REGISTRY & registry, ADMINS & admins) { registry[ToLower(tag)] = new FACTORY(admins); } @@ -122,7 +122,7 @@ class CHG_ADMIN: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(ADMINS & admins) : m_admins(admins) {} + explicit FACTORY(ADMINS & admins) : m_admins(admins) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_ADMIN(admin, m_admins); } static void Register(REGISTRY & registry, ADMINS & admins) { registry[ToLower(tag)] = new FACTORY(admins); } diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h b/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h index 9a2e81a8..abbc8f4e 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_auth_by.h @@ -41,7 +41,7 @@ class AUTH_BY : public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const USERS & users) : m_users(users) {} + explicit FACTORY(const USERS & users) : m_users(users) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new AUTH_BY(admin, m_users); } static void Register(REGISTRY & registry, const USERS & users) { registry[ToLower(tag)] = new FACTORY(users); } diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_message.h b/projects/stargazer/plugins/configuration/sgconfig/parser_message.h index 4caa354c..6ed6622d 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_message.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_message.h @@ -44,7 +44,7 @@ class SEND_MESSAGE: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(USERS & users) : m_users(users) {} + explicit FACTORY(USERS & users) : m_users(users) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new SEND_MESSAGE(admin, m_users); } static void Register(REGISTRY & registry, USERS & users) { registry[ToLower(tag)] = new FACTORY(users); } diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.h b/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.h index 6425cca1..418ae45c 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.h @@ -44,7 +44,7 @@ class GET_TARIFFS: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const TARIFFS & tariffs) : m_tariffs(tariffs) {} + explicit FACTORY(const TARIFFS & tariffs) : m_tariffs(tariffs) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_TARIFFS(admin, m_tariffs); } static void Register(REGISTRY & registry, const TARIFFS & tariffs) { registry[ToLower(tag)] = new FACTORY(tariffs); } @@ -69,7 +69,7 @@ class ADD_TARIFF: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {} + explicit FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_TARIFF(admin, m_tariffs); } static void Register(REGISTRY & registry, TARIFFS & tariffs) { registry[ToLower(tag)] = new FACTORY(tariffs); } @@ -125,7 +125,7 @@ class CHG_TARIFF: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {} + explicit FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_TARIFF(admin, m_tariffs); } static void Register(REGISTRY & registry, TARIFFS & tariffs) { registry[ToLower(tag)] = new FACTORY(tariffs); } diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_users.h b/projects/stargazer/plugins/configuration/sgconfig/parser_users.h index c9f72389..cbf25915 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_users.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_users.h @@ -48,7 +48,7 @@ class GET_USERS: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(USERS & users) : m_users(users) {} + explicit FACTORY(USERS & users) : m_users(users) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USERS(admin, m_users); } static void Register(REGISTRY & registry, USERS & users) { registry[ToLower(tag)] = new FACTORY(users); } @@ -76,7 +76,7 @@ class GET_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const USERS & users) : m_users(users) {} + explicit FACTORY(const USERS & users) : m_users(users) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USER(admin, m_users); } static void Register(REGISTRY & registry, const USERS & users) { registry[ToLower(tag)] = new FACTORY(users); } @@ -103,7 +103,7 @@ class ADD_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(USERS & users) : m_users(users) {} + explicit FACTORY(USERS & users) : m_users(users) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_USER(admin, m_users); } static void Register(REGISTRY & registry, USERS & users) { registry[ToLower(tag)] = new FACTORY(users); } @@ -176,7 +176,7 @@ class DEL_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(USERS & users) : m_users(users) {} + explicit FACTORY(USERS & users) : m_users(users) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_USER(admin, m_users); } static void Register(REGISTRY & registry, USERS & users) { registry[ToLower(tag)] = new FACTORY(users); } @@ -205,7 +205,7 @@ class CHECK_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const USERS & users) : m_users(users) {} + explicit FACTORY(const USERS & users) : m_users(users) {} virtual BASE_PARSER * create(const ADMIN & admin) { return new CHECK_USER(admin, m_users); } static void Register(REGISTRY & registry, const USERS & users) { registry[ToLower(tag)] = new FACTORY(users); } diff --git a/projects/stargazer/plugins/other/ping/ping.h b/projects/stargazer/plugins/other/ping/ping.h index cfab1e55..34bbbc52 100644 --- a/projects/stargazer/plugins/other/ping/ping.h +++ b/projects/stargazer/plugins/other/ping/ping.h @@ -7,11 +7,6 @@ #ifndef PING_H #define PING_H -#include - -#include -#include - #include "stg/os_int.h" #include "stg/plugin.h" #include "stg/module_settings.h" @@ -21,6 +16,11 @@ #include "stg/users.h" #include "stg/logger.h" +#include +#include + +#include + extern "C" PLUGIN * GetPlugin(); class PING; @@ -63,7 +63,7 @@ private: //----------------------------------------------------------------------------- class ADD_USER_NONIFIER_PING: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE(), ping(p) {} + explicit ADD_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE(), ping(p) {} virtual ~ADD_USER_NONIFIER_PING() {} void Notify(const USER_PTR & user); @@ -76,7 +76,7 @@ private: //----------------------------------------------------------------------------- class DEL_USER_NONIFIER_PING: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE(), ping(p) {} + explicit DEL_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE(), ping(p) {} virtual ~DEL_USER_NONIFIER_PING() {} void Notify(const USER_PTR & user); @@ -124,7 +124,7 @@ public: void DelUser(USER_PTR u); private: - PING(const PING & rvalue); + explicit PING(const PING & rvalue); PING & operator=(const PING & rvalue); void GetUsers(); diff --git a/projects/stargazer/plugins/other/rscript/rscript.cpp b/projects/stargazer/plugins/other/rscript/rscript.cpp index 4433dafd..1e842d25 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.cpp +++ b/projects/stargazer/plugins/other/rscript/rscript.cpp @@ -19,14 +19,10 @@ * Author : Maxim Mamontov */ -#include +#include "rscript.h" -#include -#include -#include -#include -#include -#include +#include "ur_functor.h" +#include "send_functor.h" #include "stg/common.h" #include "stg/locker.h" @@ -34,9 +30,17 @@ #include "stg/user_property.h" #include "stg/plugin_creator.h" #include "stg/logger.h" -#include "rscript.h" -#include "ur_functor.h" -#include "send_functor.h" + +#include + +#include +#include +#include +#include +#include + +#include +#include extern volatile time_t stgTime; @@ -47,7 +51,7 @@ namespace { template struct USER_IS { - USER_IS(USER_PTR u) : user(u) {} + explicit USER_IS(USER_PTR u) : user(u) {} bool operator()(const T & notifier) { return notifier.GetUser() == user; } USER_PTR user; diff --git a/projects/stargazer/plugins/other/rscript/rscript.h b/projects/stargazer/plugins/other/rscript/rscript.h index 0de1ea2e..4fb0ac73 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.h +++ b/projects/stargazer/plugins/other/rscript/rscript.h @@ -22,14 +22,6 @@ #ifndef RSCRIPT_H #define RSCRIPT_H -#include - -#include -#include -#include -#include -#include - #include "stg/plugin.h" #include "stg/module_settings.h" #include "stg/os_int.h" @@ -41,6 +33,14 @@ #include "nrmap_parser.h" +#include +#include +#include +#include +#include + +#include + extern "C" PLUGIN * GetPlugin(); #define RS_DEBUG (1) @@ -60,7 +60,7 @@ class DisconnectUser; //----------------------------------------------------------------------------- class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER(REMOTE_SCRIPT & r) + explicit ADD_USER_NONIFIER(REMOTE_SCRIPT & r) : NOTIFIER_BASE(), rs(r) {} virtual ~ADD_USER_NONIFIER() {} void Notify(const USER_PTR & user); @@ -74,7 +74,7 @@ private: //----------------------------------------------------------------------------- class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER(REMOTE_SCRIPT & r) + explicit DEL_USER_NONIFIER(REMOTE_SCRIPT & r) : NOTIFIER_BASE(), rs(r) {} virtual ~DEL_USER_NONIFIER() {} void Notify(const USER_PTR & user); @@ -138,7 +138,8 @@ private: //----------------------------------------------------------------------------- struct USER { USER(const std::vector & r, USER_PTR it) - : user(it), + : lastSentTime(0), + user(it), routers(r), shortPacketsCount(0), ip(user->GetCurrIP()) @@ -257,7 +258,7 @@ private: //----------------------------------------------------------------------------- class DisconnectUser : public std::unary_function &, void> { public: - DisconnectUser(REMOTE_SCRIPT & rs) : rscript(rs) {} + explicit DisconnectUser(REMOTE_SCRIPT & rs) : rscript(rs) {} void operator()(std::pair & p) { rscript.Send(p.second, true); diff --git a/projects/stargazer/plugins/other/rscript/send_functor.h b/projects/stargazer/plugins/other/rscript/send_functor.h index a14fe20b..baa4c118 100644 --- a/projects/stargazer/plugins/other/rscript/send_functor.h +++ b/projects/stargazer/plugins/other/rscript/send_functor.h @@ -27,12 +27,13 @@ #ifndef __SEND_FUNCTOR_H__ #define __SEND_FUNCTOR_H__ -#include -#include +#include "stg/os_int.h" #include -#include "stg/os_int.h" +#include +#include +#include class PacketSender : public std::unary_function { public: diff --git a/projects/stargazer/plugins/other/rscript/ur_functor.h b/projects/stargazer/plugins/other/rscript/ur_functor.h index 95382400..9ecf2bc5 100644 --- a/projects/stargazer/plugins/other/rscript/ur_functor.h +++ b/projects/stargazer/plugins/other/rscript/ur_functor.h @@ -21,14 +21,14 @@ #ifndef __UR_FUNCTOR_H__ #define __UR_FUNCTOR_H__ -#include -#include -#include +#include "rscript.h" #include "stg/os_int.h" #include "stg/common.h" -#include "rscript.h" +#include +#include +#include namespace RS { @@ -36,7 +36,7 @@ namespace RS class UpdateRouter : public std::unary_function, void> { public: - UpdateRouter(REMOTE_SCRIPT & t) + explicit UpdateRouter(REMOTE_SCRIPT & t) : obj(t) {} void operator() (std::pair & val) @@ -60,7 +60,7 @@ public: { obj.SendDirect(val.second, *oldIt, true); // Disconnect on old router ++oldIt; - } + } else if (*oldIt < *newIt) { obj.SendDirect(val.second, *oldIt, true); // Disconnect on old router @@ -73,8 +73,7 @@ public: } else { - if (oldIt != val.second.routers.end()) - ++oldIt; + ++oldIt; if (newIt != newRouters.end()) ++newIt; } diff --git a/projects/stargazer/plugins/other/smux/sensors.h b/projects/stargazer/plugins/other/smux/sensors.h index 3787611f..35de996c 100644 --- a/projects/stargazer/plugins/other/smux/sensors.h +++ b/projects/stargazer/plugins/other/smux/sensors.h @@ -29,7 +29,7 @@ typedef std::map Sensors; class TotalUsersSensor : public Sensor { public: - TotalUsersSensor(const USERS & u) : users(u) {} + explicit TotalUsersSensor(const USERS & u) : users(u) {} virtual ~TotalUsersSensor() {} bool GetValue(ObjectSyntax_t * objectSyntax) const @@ -49,7 +49,7 @@ class TotalUsersSensor : public Sensor { class UsersSensor : public Sensor { public: - UsersSensor(USERS & u) : users(u) {} + explicit UsersSensor(USERS & u) : users(u) {} virtual ~UsersSensor() {} bool GetValue(ObjectSyntax_t * objectSyntax) const; @@ -65,7 +65,7 @@ class UsersSensor : public Sensor { class ConnectedUsersSensor : public UsersSensor { public: - ConnectedUsersSensor(USERS & u) : UsersSensor(u) {} + explicit ConnectedUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~ConnectedUsersSensor() {} private: @@ -75,7 +75,7 @@ class ConnectedUsersSensor : public UsersSensor { class AuthorizedUsersSensor : public UsersSensor { public: - AuthorizedUsersSensor(USERS & u) : UsersSensor(u) {} + explicit AuthorizedUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~AuthorizedUsersSensor() {} private: @@ -85,7 +85,7 @@ class AuthorizedUsersSensor : public UsersSensor { class AlwaysOnlineUsersSensor : public UsersSensor { public: - AlwaysOnlineUsersSensor(USERS & u) : UsersSensor(u) {} + explicit AlwaysOnlineUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~AlwaysOnlineUsersSensor() {} private: @@ -95,7 +95,7 @@ class AlwaysOnlineUsersSensor : public UsersSensor { class NoCashUsersSensor : public UsersSensor { public: - NoCashUsersSensor(USERS & u) : UsersSensor(u) {} + explicit NoCashUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~NoCashUsersSensor() {} private: @@ -105,7 +105,7 @@ class NoCashUsersSensor : public UsersSensor { class DisabledDetailStatsUsersSensor : public UsersSensor { public: - DisabledDetailStatsUsersSensor(USERS & u) : UsersSensor(u) {} + explicit DisabledDetailStatsUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~DisabledDetailStatsUsersSensor() {} private: @@ -115,7 +115,7 @@ class DisabledDetailStatsUsersSensor : public UsersSensor { class DisabledUsersSensor : public UsersSensor { public: - DisabledUsersSensor(USERS & u) : UsersSensor(u) {} + explicit DisabledUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~DisabledUsersSensor() {} private: @@ -125,7 +125,7 @@ class DisabledUsersSensor : public UsersSensor { class PassiveUsersSensor : public UsersSensor { public: - PassiveUsersSensor(USERS & u) : UsersSensor(u) {} + explicit PassiveUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~PassiveUsersSensor() {} private: @@ -135,7 +135,7 @@ class PassiveUsersSensor : public UsersSensor { class CreditUsersSensor : public UsersSensor { public: - CreditUsersSensor(USERS & u) : UsersSensor(u) {} + explicit CreditUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~CreditUsersSensor() {} private: @@ -145,7 +145,7 @@ class CreditUsersSensor : public UsersSensor { class FreeMbUsersSensor : public UsersSensor { public: - FreeMbUsersSensor(USERS & u) : UsersSensor(u) {} + explicit FreeMbUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~FreeMbUsersSensor() {} private: @@ -155,7 +155,7 @@ class FreeMbUsersSensor : public UsersSensor { class TariffChangeUsersSensor : public UsersSensor { public: - TariffChangeUsersSensor(USERS & u) : UsersSensor(u) {} + explicit TariffChangeUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~TariffChangeUsersSensor() {} private: @@ -165,7 +165,7 @@ class TariffChangeUsersSensor : public UsersSensor { class ActiveUsersSensor : public UsersSensor { public: - ActiveUsersSensor(USERS & u) : UsersSensor(u) {} + explicit ActiveUsersSensor(USERS & u) : UsersSensor(u) {} virtual ~ActiveUsersSensor() {} private: @@ -174,7 +174,7 @@ class ActiveUsersSensor : public UsersSensor { class TotalTariffsSensor : public Sensor { public: - TotalTariffsSensor(const TARIFFS & t) : tariffs(t) {} + explicit TotalTariffsSensor(const TARIFFS & t) : tariffs(t) {} virtual ~TotalTariffsSensor() {} bool GetValue(ObjectSyntax_t * objectSyntax) const @@ -194,7 +194,7 @@ class TotalTariffsSensor : public Sensor { class TotalAdminsSensor : public Sensor { public: - TotalAdminsSensor(const ADMINS & a) : admins(a) {} + explicit TotalAdminsSensor(const ADMINS & a) : admins(a) {} virtual ~TotalAdminsSensor() {} bool GetValue(ObjectSyntax_t * objectSyntax) const @@ -214,7 +214,7 @@ class TotalAdminsSensor : public Sensor { class TotalServicesSensor : public Sensor { public: - TotalServicesSensor(const SERVICES & s) : services(s) {} + explicit TotalServicesSensor(const SERVICES & s) : services(s) {} virtual ~TotalServicesSensor() {} bool GetValue(ObjectSyntax_t * objectSyntax) const @@ -234,7 +234,7 @@ class TotalServicesSensor : public Sensor { class TotalCorporationsSensor : public Sensor { public: - TotalCorporationsSensor(const CORPORATIONS & c) : corporations(c) {} + explicit TotalCorporationsSensor(const CORPORATIONS & c) : corporations(c) {} virtual ~TotalCorporationsSensor() {} bool GetValue(ObjectSyntax_t * objectSyntax) const @@ -254,7 +254,7 @@ class TotalCorporationsSensor : public Sensor { class TotalRulesSensor : public Sensor { public: - TotalRulesSensor(const TRAFFCOUNTER & t) : traffcounter(t) {} + explicit TotalRulesSensor(const TRAFFCOUNTER & t) : traffcounter(t) {} virtual ~TotalRulesSensor() {} bool GetValue(ObjectSyntax_t * objectSyntax) const @@ -275,7 +275,7 @@ class TotalRulesSensor : public Sensor { template class ConstSensor : public Sensor { public: - ConstSensor(const T & v) : value(v) {} + explicit ConstSensor(const T & v) : value(v) {} virtual ~ConstSensor() {} bool GetValue(ObjectSyntax * objectSyntax) const diff --git a/projects/stargazer/plugins/other/smux/smux.h b/projects/stargazer/plugins/other/smux/smux.h index 3b217eb7..721f0204 100644 --- a/projects/stargazer/plugins/other/smux/smux.h +++ b/projects/stargazer/plugins/other/smux/smux.h @@ -74,7 +74,7 @@ private: //----------------------------------------------------------------------------- class ADD_DEL_TARIFF_NOTIFIER : public NOTIFIER_BASE, private NONCOPYABLE { public: - ADD_DEL_TARIFF_NOTIFIER(SMUX & s) + explicit ADD_DEL_TARIFF_NOTIFIER(SMUX & s) : NOTIFIER_BASE(), smux(s) {} void Notify(const TARIFF_DATA &); @@ -84,7 +84,7 @@ private: //----------------------------------------------------------------------------- class ADD_USER_NOTIFIER : public NOTIFIER_BASE, private NONCOPYABLE { public: - ADD_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE(), smux(s) {} + explicit ADD_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE(), smux(s) {} void Notify(const USER_PTR &); private: @@ -93,7 +93,7 @@ private: //----------------------------------------------------------------------------- class DEL_USER_NOTIFIER : public NOTIFIER_BASE, private NONCOPYABLE { public: - DEL_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE(), smux(s) {} + explicit DEL_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE(), smux(s) {} void Notify(const USER_PTR &); private: diff --git a/projects/stargazer/plugins/other/smux/tables.h b/projects/stargazer/plugins/other/smux/tables.h index ea0bc627..a1f97f67 100644 --- a/projects/stargazer/plugins/other/smux/tables.h +++ b/projects/stargazer/plugins/other/smux/tables.h @@ -11,7 +11,7 @@ class USERS; class TableSensor { public: - TableSensor(const std::string & p) : prefix(p) {} + explicit TableSensor(const std::string & p) : prefix(p) {} virtual ~TableSensor() {} const std::string & GetPrefix() const { return prefix; } diff --git a/projects/stargazer/plugins/other/smux/types.h b/projects/stargazer/plugins/other/smux/types.h index 5498d2eb..2b54f2a2 100644 --- a/projects/stargazer/plugins/other/smux/types.h +++ b/projects/stargazer/plugins/other/smux/types.h @@ -9,11 +9,11 @@ class OID { public: - OID(const std::string & str); + explicit OID(const std::string & str); OID(const char * str, size_t length); - OID(const std::vector & arcs); + explicit OID(const std::vector & arcs); OID(const unsigned * arcs, size_t length); - OID(OBJECT_IDENTIFIER_t * oid); + explicit OID(OBJECT_IDENTIFIER_t * oid); OID(const OID & rvalue); ~OID(); diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.cpp b/projects/stargazer/plugins/store/mysql/mysql_store.cpp index 198b5f3b..8108de09 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.cpp +++ b/projects/stargazer/plugins/store/mysql/mysql_store.cpp @@ -222,12 +222,13 @@ else { if(mysql_select_db(sock, storeSettings.GetDBName().c_str())) { - errorStr = "Couldn't select database! With error:\n"; - errorStr += mysql_error(sock); - mysql_close(sock); - ret = -1; + errorStr = "Couldn't select database! With error:\n"; + errorStr += mysql_error(sock); + mysql_close(sock); + ret = -1; } - ret = CheckAllTables(sock); + else + ret = CheckAllTables(sock); } } else diff --git a/projects/stargazer/services_impl.cpp b/projects/stargazer/services_impl.cpp index 90c23f81..109a327b 100644 --- a/projects/stargazer/services_impl.cpp +++ b/projects/stargazer/services_impl.cpp @@ -107,7 +107,7 @@ while (csi != searchDescriptors.end()) { if (csi->second == si) (csi->second)++; - csi++; + ++csi; } data.remove(*si); diff --git a/projects/stargazer/services_impl.h b/projects/stargazer/services_impl.h index 56202c7a..8101f2d9 100644 --- a/projects/stargazer/services_impl.h +++ b/projects/stargazer/services_impl.h @@ -21,12 +21,6 @@ #ifndef SERVICES_IMPL_H #define SERVICES_IMPL_H -#include - -#include -#include -#include - #include "stg/services.h" #include "stg/service_conf.h" #include "stg/locker.h" @@ -34,11 +28,17 @@ #include "stg/noncopyable.h" #include "stg/logger.h" +#include +#include +#include + +#include + class ADMIN; class SERVICES_IMPL : private NONCOPYABLE, public SERVICES { public: - SERVICES_IMPL(STORE * st); + explicit SERVICES_IMPL(STORE * st); virtual ~SERVICES_IMPL() {} int Add(const SERVICE_CONF & service, const ADMIN * admin); diff --git a/projects/stargazer/settings_impl.h b/projects/stargazer/settings_impl.h index cc35393b..9bcce5b0 100644 --- a/projects/stargazer/settings_impl.h +++ b/projects/stargazer/settings_impl.h @@ -37,13 +37,13 @@ #ifndef SETTINGS_IMPL_H #define SETTINGS_IMPL_H -#include -#include - #include "stg/settings.h" #include "stg/common.h" #include "stg/module_settings.h" +#include +#include + //----------------------------------------------------------------------------- enum DETAIL_STAT_PERIOD { dsPeriod_1, @@ -57,7 +57,7 @@ class DOTCONFDocumentNode; //----------------------------------------------------------------------------- class SETTINGS_IMPL : public SETTINGS { public: - SETTINGS_IMPL(const std::string &); + explicit SETTINGS_IMPL(const std::string &); SETTINGS_IMPL(const SETTINGS_IMPL &); virtual ~SETTINGS_IMPL() {} SETTINGS_IMPL & operator=(const SETTINGS_IMPL &); diff --git a/projects/stargazer/store_loader.cpp b/projects/stargazer/store_loader.cpp index d27c0902..1529a2cc 100644 --- a/projects/stargazer/store_loader.cpp +++ b/projects/stargazer/store_loader.cpp @@ -115,6 +115,8 @@ if (!isLoaded) return true; } +delete plugin; + if (dlclose(handle)) { errorStr = "Failed to unload plugin '"; diff --git a/projects/stargazer/store_loader.h b/projects/stargazer/store_loader.h index 5245eb57..b38a46ee 100644 --- a/projects/stargazer/store_loader.h +++ b/projects/stargazer/store_loader.h @@ -31,17 +31,17 @@ #ifndef __STORE_LOADER_H__ #define __STORE_LOADER_H__ -#include - #include "stg/module_settings.h" #include "stg/noncopyable.h" +#include + class STORE; class SETTINGS_IMPL; class STORE_LOADER : private NONCOPYABLE { public: - STORE_LOADER(const SETTINGS_IMPL & settings); + explicit STORE_LOADER(const SETTINGS_IMPL & settings); ~STORE_LOADER(); bool Load(); diff --git a/projects/stargazer/tariff_impl.h b/projects/stargazer/tariff_impl.h index 0619d50b..3a12fbdf 100644 --- a/projects/stargazer/tariff_impl.h +++ b/projects/stargazer/tariff_impl.h @@ -31,14 +31,14 @@ #ifndef TARIFF_IMPL_H #define TARIFF_IMPL_H -#include +#include "stg/tariff.h" +#include "stg/os_int.h" +#include "stg/tariff_conf.h" #include #include -#include "stg/tariff.h" -#include "stg/os_int.h" -#include "stg/tariff_conf.h" +#include #define TARIFF_DAY 0 #define TARIFF_NIGHT 1 @@ -49,18 +49,14 @@ public: : TARIFF(), tariffData() {} - TARIFF_IMPL(const std::string & name) + explicit TARIFF_IMPL(const std::string & name) : TARIFF(), tariffData(name) {} - TARIFF_IMPL(const TARIFF_DATA & td) + explicit TARIFF_IMPL(const TARIFF_DATA & td) : TARIFF(), tariffData(td) {} - TARIFF_IMPL(const TARIFF_IMPL & t) - : TARIFF(), - tariffData(t.tariffData) - {} virtual ~TARIFF_IMPL() {} double GetPriceWithTraffType(uint64_t up, diff --git a/projects/stargazer/tariffs_impl.h b/projects/stargazer/tariffs_impl.h index 288f1225..55cc49b3 100644 --- a/projects/stargazer/tariffs_impl.h +++ b/projects/stargazer/tariffs_impl.h @@ -25,16 +25,16 @@ #ifndef TARIFFS_IMPL_H #define TARIFFS_IMPL_H -#include +#include "stg/tariff.h" +#include "stg/tariffs.h" +#include "stg/tariff_conf.h" +#include "tariff_impl.h" #include #include #include -#include "stg/tariff.h" -#include "stg/tariffs.h" -#include "stg/tariff_conf.h" -#include "tariff_impl.h" +#include #define TARIFF_DAY 0 #define TARIFF_NIGHT 1 @@ -47,7 +47,7 @@ class TARIFFS_IMPL : public TARIFFS { public: typedef std::list Tariffs; - TARIFFS_IMPL(STORE * store); + explicit TARIFFS_IMPL(STORE * store); virtual ~TARIFFS_IMPL(); int ReadTariffs (); const TARIFF * FindByName(const std::string & name) const; diff --git a/projects/stargazer/traffcounter_impl.cpp b/projects/stargazer/traffcounter_impl.cpp index 5223c5c4..8cc08839 100644 --- a/projects/stargazer/traffcounter_impl.cpp +++ b/projects/stargazer/traffcounter_impl.cpp @@ -188,7 +188,7 @@ while (tc->running) std::string monFile(tc->monitorDir + "/traffcounter_r"); printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", tc->monitoring, monFile.c_str()); touchTime = stgTime; - TouchFile(monFile.c_str()); + TouchFile(monFile); } if (++c % FLUSH_TIME == 0) @@ -209,7 +209,7 @@ if (monitoring && (touchTimeP + MONITOR_TIME_DELAY_SEC <= stgTime)) std::string monFile = monitorDir + "/traffcounter_p"; printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", monitoring, monFile.c_str()); touchTimeP = stgTime; - TouchFile(monFile.c_str()); + TouchFile(monFile); } STG_LOCKER lock(&mutex); @@ -509,10 +509,10 @@ void TRAFFCOUNTER_IMPL::DeterminateDir(const RAW_PACKET & packet, int * dirU, // Direction for incoming packet int * dirD) const // Direction for outgoing packet { -bool addrMatchU; -bool portMatchU; -bool addrMatchD; -bool portMatchD; +bool addrMatchU = false; +bool portMatchU = false; +bool addrMatchD = false; +bool portMatchD = false; bool foundU = false; // Was rule for U found ? bool foundD = false; // Was rule for D found ? //printfd(__FILE__, "foundU=%d, foundD=%d\n", foundU, foundD); @@ -526,7 +526,6 @@ while (ln != rules.end()) { if (!foundU) { - addrMatchU = false; portMatchU = false; switch (ln->proto) @@ -572,7 +571,6 @@ while (ln != rules.end()) if (!foundD) { - addrMatchD = false; portMatchD = false; switch (ln->proto) @@ -654,7 +652,7 @@ while (fgets(str, 1023, f)) continue; } - r = sscanf(str,"%100s %100s %100s", tp, ta, td); + r = sscanf(str,"%99s %99s %99s", tp, ta, td); if (r != 3) { printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d. There must be 3 parameters.\n", rulesFileName.c_str(), lineNumber); diff --git a/projects/stargazer/traffcounter_impl.h b/projects/stargazer/traffcounter_impl.h index 12439313..a1dfa743 100644 --- a/projects/stargazer/traffcounter_impl.h +++ b/projects/stargazer/traffcounter_impl.h @@ -28,13 +28,6 @@ #ifndef TRAFFCOUNTER_IMPL_H #define TRAFFCOUNTER_IMPL_H -#include - -#include -#include -#include -#include - #include "stg/traffcounter.h" #include "stg/os_int.h" #include "stg/logger.h" @@ -45,6 +38,13 @@ #include "eventloop.h" #include "user_impl.h" +#include +#include +#include +#include + +#include + #define PROTOMAX (5) class USERS_IMPL; @@ -147,7 +147,7 @@ private: //----------------------------------------------------------------------------- class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : + explicit ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : NOTIFIER_BASE(), traffCnt(t) {} @@ -163,7 +163,7 @@ private: //----------------------------------------------------------------------------- class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : + explicit DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : NOTIFIER_BASE(), traffCnt(t) {} diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index 36c0f84f..d6c749b7 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -134,6 +134,8 @@ USER_IMPL::USER_IMPL(const SETTINGS * s, userdata7(property.userdata7), userdata8(property.userdata8), userdata9(property.userdata9), + sessionUploadModTime(stgTime), + sessionDownloadModTime(stgTime), passiveNotifier(this), disabledNotifier(this), tariffNotifier(this), @@ -204,6 +206,8 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s, userdata7(property.userdata7), userdata8(property.userdata8), userdata9(property.userdata9), + sessionUploadModTime(stgTime), + sessionDownloadModTime(stgTime), passiveNotifier(this), disabledNotifier(this), tariffNotifier(this), @@ -298,6 +302,8 @@ USER_IMPL::USER_IMPL(const USER_IMPL & u) userdata9(property.userdata9), sessionUpload(), sessionDownload(), + sessionUploadModTime(stgTime), + sessionDownloadModTime(stgTime), passiveNotifier(this), disabledNotifier(this), tariffNotifier(this), diff --git a/projects/stargazer/user_impl.h b/projects/stargazer/user_impl.h index 77887514..8bc69664 100644 --- a/projects/stargazer/user_impl.h +++ b/projects/stargazer/user_impl.h @@ -66,7 +66,7 @@ private: class CHG_PASSIVE_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { public: - CHG_PASSIVE_NOTIFIER(USER_IMPL * u) : user(u) {} + explicit CHG_PASSIVE_NOTIFIER(USER_IMPL * u) : user(u) {} void Notify(const int & oldPassive, const int & newPassive); private: @@ -76,7 +76,7 @@ private: class CHG_DISABLED_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { public: - CHG_DISABLED_NOTIFIER(USER_IMPL * u) : user(u) {} + explicit CHG_DISABLED_NOTIFIER(USER_IMPL * u) : user(u) {} void Notify(const int & oldValue, const int & newValue); private: @@ -86,7 +86,7 @@ private: class CHG_TARIFF_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { public: - CHG_TARIFF_NOTIFIER(USER_IMPL * u) : user(u) {} + explicit CHG_TARIFF_NOTIFIER(USER_IMPL * u) : user(u) {} void Notify(const std::string & oldTariff, const std::string & newTariff); private: @@ -96,7 +96,7 @@ private: class CHG_CASH_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { public: - CHG_CASH_NOTIFIER(USER_IMPL * u) : user(u) {} + explicit CHG_CASH_NOTIFIER(USER_IMPL * u) : user(u) {} void Notify(const double & oldCash, const double & newCash); private: @@ -106,7 +106,7 @@ private: class CHG_IPS_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { public: - CHG_IPS_NOTIFIER(USER_IMPL * u) : user(u) {} + explicit CHG_IPS_NOTIFIER(USER_IMPL * u) : user(u) {} void Notify(const USER_IPS & oldIPs, const USER_IPS & newIPs); private: diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index 18d1abaf..e973d2cd 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -419,7 +419,7 @@ while (us->nonstop) { //printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", tc->monitoring, monFile.c_str()); touchTime = stgTime; - TouchFile(monFile.c_str()); + TouchFile(monFile); } stgUsleep(100000); diff --git a/stglibs/conffiles.lib/conffiles.cpp b/stglibs/conffiles.lib/conffiles.cpp index a9c3e555..9578e24f 100644 --- a/stglibs/conffiles.lib/conffiles.cpp +++ b/stglibs/conffiles.lib/conffiles.cpp @@ -70,7 +70,7 @@ if (pos != std::string::npos) return val; } //--------------------------------------------------------------------------- -std::string Trim(std::string val) +std::string Trim(const std::string& val) { return TrimR(TrimL(val)); } diff --git a/stglibs/dotconfpp.lib/include/stg/dotconfpp.h b/stglibs/dotconfpp.lib/include/stg/dotconfpp.h index 93075013..63cd7eb3 100644 --- a/stglibs/dotconfpp.lib/include/stg/dotconfpp.h +++ b/stglibs/dotconfpp.lib/include/stg/dotconfpp.h @@ -107,7 +107,7 @@ protected: virtual void error(int lineNum, const char * fileName, const char * fmt, ...); public: - DOTCONFDocument(CaseSensitive caseSensitivity = CASESENSITIVE); + explicit DOTCONFDocument(CaseSensitive caseSensitivity = CASESENSITIVE); virtual ~DOTCONFDocument(); void setErrorCallback(DOTCONFCallback _callback, void * _data) { errorCallback = _callback; errorCallbackData = _data; } diff --git a/stglibs/logger.lib/include/stg/logger.h b/stglibs/logger.lib/include/stg/logger.h index e8d625a0..5165f0fb 100644 --- a/stglibs/logger.lib/include/stg/logger.h +++ b/stglibs/logger.lib/include/stg/logger.h @@ -1,17 +1,17 @@ #ifndef STG_LOGGER_H #define STG_LOGGER_H -#include - #include +#include + class STG_LOGGER; STG_LOGGER & GetStgLogger(); //----------------------------------------------------------------------------- class STG_LOGGER_LOCKER { public: - STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); } + explicit STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); } ~STG_LOGGER_LOCKER() { pthread_mutex_unlock(mutex); } private: diff --git a/stglibs/pinger.lib/include/stg/pinger.h b/stglibs/pinger.lib/include/stg/pinger.h index 91608dbb..f31cc270 100644 --- a/stglibs/pinger.lib/include/stg/pinger.h +++ b/stglibs/pinger.lib/include/stg/pinger.h @@ -87,7 +87,7 @@ public: typedef std::multimap PingIPs; typedef PingIPs::size_type SizeType; - STG_PINGER(time_t delay = 15); + explicit STG_PINGER(time_t delay = 15); ~STG_PINGER(); int Start();