From 41c42a92e9d6322c238c062c3895d95b244b36e4 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Fri, 25 Mar 2022 09:39:23 -0700 Subject: [PATCH] Code changes after analyzer --- CMakeLists.txt | 4 + build | 2 +- src/APStats.cpp | 2 +- src/Daemon.cpp | 4 +- src/Daemon.h | 2 +- src/DeviceStatusReceiver.cpp | 6 - src/HealthReceiver.cpp | 6 - src/RESTAPI/RESTAPI_analytics_db_helpers.h | 1 - .../RESTAPI_board_timepoint_handler.cpp | 2 +- src/RESTObjects/RESTAPI_AnalyticsObjects.cpp | 4 +- src/RESTObjects/RESTAPI_AnalyticsObjects.h | 2 +- src/RESTObjects/RESTAPI_FMSObjects.cpp | 2 +- src/RESTObjects/RESTAPI_ProvObjects.cpp | 2 +- src/StorageService.cpp | 2 +- src/VenueWatcher.h | 4 +- src/framework/ConfigurationValidator.cpp | 2 +- src/framework/MicroService.h | 142 +++++++++--------- src/framework/orm.h | 17 ++- src/sdks/SDK_prov.cpp | 2 +- src/storage/storage_boards.cpp | 2 +- src/storage/storage_boards.h | 1 + src/storage/storage_timepoints.cpp | 2 +- src/storage/storage_timepoints.h | 1 + 23 files changed, 102 insertions(+), 112 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c87dc26..b55b448 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,10 @@ else() find_package(Poco REQUIRED COMPONENTS JSON Crypto JWT Net Util NetSSL Data DataSQLite DataPostgreSQL DataMySQL) endif() +add_compile_options(-fsanitize=address -Wall -Wextra) +add_compile_options(-fsanitize=address) +add_link_options(-fsanitize=address) + include_directories(/usr/local/include /usr/local/opt/openssl/include src include/kafka /usr/local/opt/mysql-client/include) configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY) diff --git a/build b/build index d99e90e..3e932fe 100644 --- a/build +++ b/build @@ -1 +1 @@ -29 \ No newline at end of file +34 \ No newline at end of file diff --git a/src/APStats.cpp b/src/APStats.cpp index bb4d5c1..ad7f931 100644 --- a/src/APStats.cpp +++ b/src/APStats.cpp @@ -140,7 +140,7 @@ namespace OpenWifi { GetJSON("tx_msdu",tid_stat,E.tx_msdu, (uint64_t)0 ); GetJSON("tx_msdu_failed",tid_stat,E.tx_msdu_failed, (uint64_t)0 ); GetJSON("tx_msdu_retries",tid_stat,E.tx_msdu_retries, (uint64_t)0 ); - TP.tidstat.push_back(E); + TP.tidstats.push_back(E); } } diff --git a/src/Daemon.cpp b/src/Daemon.cpp index d399af6..37672e5 100644 --- a/src/Daemon.cpp +++ b/src/Daemon.cpp @@ -39,11 +39,11 @@ namespace OpenWifi { return instance_; } - void Daemon::initialize() { + void Daemon::initialize([[maybe_unused]] Poco::Util::Application &self) { + std::cout << "Daemon initializing" << std::endl; } void MicroServicePostInitialization() { - Daemon()->initialize(); } } diff --git a/src/Daemon.h b/src/Daemon.h index 0b145e7..d4e1962 100644 --- a/src/Daemon.h +++ b/src/Daemon.h @@ -37,7 +37,7 @@ namespace OpenWifi { const SubSystemVec & SubSystems) : MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {}; - void initialize(); + void initialize(Poco::Util::Application &self); static Daemon *instance(); inline OpenWifi::AnalyticsDashboard & GetDashboard() { return DB_; } Poco::Logger & Log() { return Poco::Logger::get(AppName()); } diff --git a/src/DeviceStatusReceiver.cpp b/src/DeviceStatusReceiver.cpp index 0638e20..7731be4 100644 --- a/src/DeviceStatusReceiver.cpp +++ b/src/DeviceStatusReceiver.cpp @@ -22,12 +22,6 @@ namespace OpenWifi { Worker_.join(); } - static void AssignIfPresent(const Poco::JSON::Object::Ptr & Obj, const std::string &Key, std::string &Value) { - if(Obj->has(Key)) { - Value = Obj->get(Key).toString(); - } - } - void DeviceStatusReceiver::run() { Poco::AutoPtr Note(Queue_.waitDequeueNotification()); while(Note && Running_) { diff --git a/src/HealthReceiver.cpp b/src/HealthReceiver.cpp index 18d79e0..9c71463 100644 --- a/src/HealthReceiver.cpp +++ b/src/HealthReceiver.cpp @@ -22,12 +22,6 @@ namespace OpenWifi { Worker_.join(); } - static void AssignIfPresent(const Poco::JSON::Object::Ptr & Obj, const std::string &Key, std::string &Value) { - if(Obj->has(Key)) { - Value = Obj->get(Key).toString(); - } - } - void HealthReceiver::run() { Poco::AutoPtr Note(Queue_.waitDequeueNotification()); while(Note && Running_) { diff --git a/src/RESTAPI/RESTAPI_analytics_db_helpers.h b/src/RESTAPI/RESTAPI_analytics_db_helpers.h index 66a2de2..c183f75 100644 --- a/src/RESTAPI/RESTAPI_analytics_db_helpers.h +++ b/src/RESTAPI/RESTAPI_analytics_db_helpers.h @@ -44,7 +44,6 @@ namespace OpenWifi { void ListHandler(const char *BlockName, DB &DBInstance, RESTAPIHandler &R) { typedef typename DB::RecordVec RecVec; - typedef typename DB::RecordName RecType; if (!R.QB_.Select.empty()) { return ReturnRecordList(BlockName, DBInstance, R); diff --git a/src/RESTAPI/RESTAPI_board_timepoint_handler.cpp b/src/RESTAPI/RESTAPI_board_timepoint_handler.cpp index 2ec9c15..8338e26 100644 --- a/src/RESTAPI/RESTAPI_board_timepoint_handler.cpp +++ b/src/RESTAPI/RESTAPI_board_timepoint_handler.cpp @@ -27,7 +27,7 @@ namespace OpenWifi { typedef std::vector< std::vector> split_points; - static void split_in_buckets(uint32_t buckets,std::vector &p,split_points &sp) { + static void split_in_buckets([[maybe_unused]] uint32_t buckets,std::vector &p,split_points &sp) { std::string cur_sn; uint32_t cur_bucket=0; for(const auto &i:p) { diff --git a/src/RESTObjects/RESTAPI_AnalyticsObjects.cpp b/src/RESTObjects/RESTAPI_AnalyticsObjects.cpp index 77d8ea1..beafb54 100644 --- a/src/RESTObjects/RESTAPI_AnalyticsObjects.cpp +++ b/src/RESTObjects/RESTAPI_AnalyticsObjects.cpp @@ -14,7 +14,7 @@ namespace OpenWifi::AnalyticsObjects { void Report::reset() { } - void Report::to_json(Poco::JSON::Object &Obj) const { + void Report::to_json([[maybe_unused]] Poco::JSON::Object &Obj) const { } void VenueInfo::to_json(Poco::JSON::Object &Obj) const { @@ -167,6 +167,7 @@ namespace OpenWifi::AnalyticsObjects { field_to_json(Obj,"inactive",inactive); field_to_json(Obj,"tx_rate",tx_rate); field_to_json(Obj,"rx_rate",rx_rate); + field_to_json(Obj,"tidstats",tidstats); } bool UETimePoint::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -184,6 +185,7 @@ namespace OpenWifi::AnalyticsObjects { field_from_json(Obj,"inactive",inactive); field_from_json(Obj,"tx_rate",tx_rate); field_from_json(Obj,"rx_rate",rx_rate); + field_from_json(Obj,"tidstats",tidstats); return true; } catch(...) { diff --git a/src/RESTObjects/RESTAPI_AnalyticsObjects.h b/src/RESTObjects/RESTAPI_AnalyticsObjects.h index 487acab..77815d3 100644 --- a/src/RESTObjects/RESTAPI_AnalyticsObjects.h +++ b/src/RESTObjects/RESTAPI_AnalyticsObjects.h @@ -123,7 +123,7 @@ namespace OpenWifi { inactive = 0; UE_rate tx_rate, rx_rate; - std::vector tidstat; + std::vector tidstats; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); diff --git a/src/RESTObjects/RESTAPI_FMSObjects.cpp b/src/RESTObjects/RESTAPI_FMSObjects.cpp index 7d40630..b6f6220 100644 --- a/src/RESTObjects/RESTAPI_FMSObjects.cpp +++ b/src/RESTObjects/RESTAPI_FMSObjects.cpp @@ -236,7 +236,7 @@ namespace OpenWifi::FMSObjects { snapshot = std::time(nullptr); } - bool DeviceReport::from_json(const Poco::JSON::Object::Ptr &Obj) { + bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) { try { return true; diff --git a/src/RESTObjects/RESTAPI_ProvObjects.cpp b/src/RESTObjects/RESTAPI_ProvObjects.cpp index 706ed16..05fe7f4 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.cpp +++ b/src/RESTObjects/RESTAPI_ProvObjects.cpp @@ -837,7 +837,7 @@ namespace OpenWifi::ProvObjects { return true; } - bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I) { + bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) { I.modified = I.created = OpenWifi::Now(); I.id = MicroService::CreateUUID(); return true; diff --git a/src/StorageService.cpp b/src/StorageService.cpp index 79cf624..0aded93 100644 --- a/src/StorageService.cpp +++ b/src/StorageService.cpp @@ -31,7 +31,7 @@ namespace OpenWifi { return 0; } - void Storage::onTimer(Poco::Timer &timer) { + void Storage::onTimer([[maybe_unused]] Poco::Timer &timer) { } void Storage::run() { diff --git a/src/VenueWatcher.h b/src/VenueWatcher.h index e09c9f7..a742bd2 100644 --- a/src/VenueWatcher.h +++ b/src/VenueWatcher.h @@ -24,13 +24,13 @@ namespace OpenWifi { SerialNumber_(SerialNumber) { } inline std::shared_ptr & Payload() { return Payload_; } - inline const auto SerialNumber() { return SerialNumber_; } + inline auto SerialNumber() { return SerialNumber_; } inline uint64_t Type() { return Type_; } private: std::shared_ptr Payload_; - uint64_t SerialNumber_=0; MsgType Type_; + uint64_t SerialNumber_=0; }; class VenueWatcher : public Poco::Runnable { diff --git a/src/framework/ConfigurationValidator.cpp b/src/framework/ConfigurationValidator.cpp index d81b8e0..3ce2d15 100644 --- a/src/framework/ConfigurationValidator.cpp +++ b/src/framework/ConfigurationValidator.cpp @@ -2614,7 +2614,7 @@ namespace OpenWifi { return true; } - void ConfigurationValidator::reinitialize(Poco::Util::Application &self) { + void ConfigurationValidator::reinitialize([[maybe_unused]] Poco::Util::Application &self) { Logger().information("Reinitializing."); Working_ = Initialized_ = false; Init(); diff --git a/src/framework/MicroService.h b/src/framework/MicroService.h index 1248c24..e645e94 100644 --- a/src/framework/MicroService.h +++ b/src/framework/MicroService.h @@ -575,7 +575,7 @@ namespace OpenWifi::RESTAPI_utils { try { Poco::JSON::Parser P; auto Object = P.parse(ObjectString).template extract(); - for (auto const i : *Object) { + for (auto const &i : *Object) { auto InnerObject = i.template extract(); T Obj; Obj.from_json(InnerObject); @@ -751,15 +751,12 @@ namespace OpenWifi::Utils { using byte = std::uint8_t; - [[nodiscard]] inline std::string base64encode(const byte *input, unsigned long size) { + [[nodiscard]] inline std::string base64encode(const byte *input, uint32_t size) { std::string encoded; encoded.reserve(((size / 3) + (size % 3 > 0)) * 4); - std::uint32_t temp; - - std::size_t i; - - int ee = (int)(size/3); + std::uint32_t temp,i,ee; + ee = (size/3); for (i = 0; i < 3*ee; ++i) { temp = input[i++] << 16; @@ -1257,7 +1254,7 @@ namespace OpenWifi { inline void exception(const std::exception & E) { Poco::Thread * CurrentThread = Poco::Thread::current(); - App_.logger().warning(fmt::format("std::exception in ",CurrentThread->getName())); + App_.logger().warning(fmt::format("std::exception in {}: {}",CurrentThread->getName(),E.what())); } inline void exception() { @@ -1282,9 +1279,10 @@ namespace OpenWifi { public: explicit MyPrivateKeyPassphraseHandler(const std::string &Password, Poco::Logger & Logger): PrivateKeyPassphraseHandler(true), - Logger_(Logger), - Password_(Password) {} - void onPrivateKeyRequested(const void * pSender,std::string & privateKey) { + Password_(Password), + Logger_(Logger) + {} + void onPrivateKeyRequested([[maybe_unused]] const void * pSender,std::string & privateKey) { Logger_.information("Returning key passphrase."); privateKey = Password_; }; @@ -1302,11 +1300,19 @@ namespace OpenWifi { Poco::Net::Context::VerificationMode M = Poco::Net::Context::VerificationMode::VERIFY_RELAXED, int backlog = 64) - : address_(std::move(Address)), port_(port), key_file_(std::move(Key_file)), - cert_file_(std::move(Cert_file)), root_ca_(std::move(RootCa)), - issuer_cert_file_(std::move(Issuer)), client_cas_(std::move(ClientCas)), - cas_(std::move(Cas)), key_file_password_(std::move(Key_file_password)), - name_(std::move(Name)), level_(M), backlog_(backlog){}; + : address_(std::move(Address)), + port_(port), + cert_file_(std::move(Cert_file)), + key_file_(std::move(Key_file)), + root_ca_(std::move(RootCa)), + key_file_password_(std::move(Key_file_password)), + issuer_cert_file_(std::move(Issuer)), + client_cas_(std::move(ClientCas)), + cas_(std::move(Cas)), + name_(std::move(Name)), + backlog_(backlog), + level_(M) + {}; [[nodiscard]] inline const std::string &Address() const { return address_; }; [[nodiscard]] inline uint32_t Port() const { return port_; }; @@ -1394,7 +1400,7 @@ namespace OpenWifi { } } - [[nodiscard]] inline Poco::Net::ServerSocket CreateSocket(Poco::Logger &L) const { + [[nodiscard]] inline Poco::Net::ServerSocket CreateSocket([[maybe_unused]] Poco::Logger &L) const { Poco::Net::Context::Params P; if (address_ == "*") { @@ -1532,6 +1538,7 @@ namespace OpenWifi { private: std::string address_; + uint32_t port_; std::string cert_file_; std::string key_file_; std::string root_ca_; @@ -1539,7 +1546,6 @@ namespace OpenWifi { std::string issuer_cert_file_; std::string client_cas_; std::string cas_; - uint32_t port_; std::string name_; int backlog_; Poco::Net::Context::VerificationMode level_; @@ -1553,10 +1559,10 @@ namespace OpenWifi { inline void initialize(Poco::Util::Application &self) override; inline void uninitialize() override { } - inline void reinitialize(Poco::Util::Application &self) override { + inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override { Logger().information("Reloading of this subsystem is not supported."); } - inline void defineOptions(Poco::Util::OptionSet &options) override { + inline void defineOptions([[maybe_unused]] Poco::Util::OptionSet &options) override { } inline const std::string & Name() const { return Name_; }; inline const char * name() const override { return Name_.c_str(); } @@ -1575,7 +1581,7 @@ namespace OpenWifi { struct LoggerWrapper { Poco::Logger &L; - inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {} + explicit inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {} }; protected: @@ -1776,17 +1782,17 @@ namespace OpenWifi { : Bindings_(std::move(map)), Logger_(l), Methods_(std::move(Methods)), - Server_(Server), - TransactionId_(TransactionId), Internal_(Internal), - AlwaysAuthorize_(AlwaysAuthorize), RateLimited_(RateLimited), - MyRates_(Profile), - SubOnlyService_(SubscriberOnly) - { + SubOnlyService_(SubscriberOnly), + AlwaysAuthorize_(AlwaysAuthorize), + Server_(Server), + MyRates_(Profile), + TransactionId_(TransactionId) + { } - inline bool RoleIsAuthorized(const std::string & Path, const std::string & Method, std::string & Reason) { + inline bool RoleIsAuthorized([[maybe_unused]] const std::string & Path, [[maybe_unused]] const std::string & Method, [[maybe_unused]] std::string & Reason) { return true; } @@ -1854,7 +1860,7 @@ namespace OpenWifi { continue; bool Matched = true; - for (auto i = 0; i != PathItems.size() && Matched; i++) { + for (size_t i = 0; i != PathItems.size() && Matched; i++) { if (PathItems[i] != ParamItems[i]) { if (ParamItems[i][0] == '{') { auto ParamName = ParamItems[i].substr(1, ParamItems[i].size() - 2); @@ -2138,7 +2144,7 @@ namespace OpenWifi { Response->sendFile(File.path(),MT.ContentType); } - inline void SendFile(Poco::TemporaryFile &TempAvatar, const std::string &Type, const std::string & Name) { + inline void SendFile(Poco::TemporaryFile &TempAvatar, [[maybe_unused]] const std::string &Type, const std::string & Name) { Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK); AddCORS(); auto MT = Utils::FindMediaType(Name); @@ -2640,7 +2646,7 @@ namespace OpenWifi { } [[nodiscard]] inline std::string WrapSystemId(const std::string & PayLoad) { - return std::move( SystemInfoWrapper_ + PayLoad + "}"); + return SystemInfoWrapper_ + PayLoad + "}"; } [[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; } @@ -2712,7 +2718,7 @@ namespace OpenWifi { } inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) { - return ((T.expires_in_+T.created_)Logger()), - Server_(Server) - { - - } - + ExtRequestHandlerFactory() = default; inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override { try { Poco::URI uri(Request.getURI()); @@ -2916,17 +2916,14 @@ namespace OpenWifi { } return nullptr; } - private: static inline std::atomic_uint64_t TransactionId_ = 1; - Poco::Logger &Logger_; - RESTAPI_GenericServer &Server_; }; class LogMuxer : public Poco::Channel { public: - inline std::string getProperty( const std::string &p ) const final { + inline std::string getProperty( [[maybe_unused]] const std::string &p ) const final { return ""; } @@ -2977,7 +2974,7 @@ namespace OpenWifi { } } - inline void setProperty(const std::string &name, const std::string &value) final { + inline void setProperty([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) final { } @@ -3039,10 +3036,7 @@ namespace OpenWifi { class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory { public: - explicit IntRequestHandlerFactory(RESTAPI_GenericServer & Server) : - Logger_(RESTAPI_IntServer()->Logger()), - Server_(Server){} - + inline IntRequestHandlerFactory() = default; inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override { Poco::URI uri(Request.getURI()); auto *Path = uri.getPath().c_str(); @@ -3050,8 +3044,6 @@ namespace OpenWifi { } private: static inline std::atomic_uint64_t TransactionId_ = 1; - Poco::Logger &Logger_; - RESTAPI_GenericServer &Server_; }; struct MicroServiceMeta { @@ -3198,7 +3190,6 @@ namespace OpenWifi { bool DebugMode_ = false; std::string DataDir_; std::string WWWAssetsDir_; - SubSystemVec SubSystems_; Poco::Crypto::CipherFactory & CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory(); Poco::Crypto::Cipher * Cipher_ = nullptr; Poco::SHA2Engine SHA2_; @@ -3217,6 +3208,7 @@ namespace OpenWifi { std::string DAEMON_CONFIG_ENV_VAR; std::string DAEMON_APP_NAME; uint64_t DAEMON_BUS_TIMER; + SubSystemVec SubSystems_; bool NoAPISecurity_=false; bool NoBuiltInCrypto_=false; Poco::JWT::Signer Signer_; @@ -3226,7 +3218,7 @@ namespace OpenWifi { std::exit(Reason); } - inline void MicroService::BusMessageReceived(const std::string &Key, const std::string & Payload) { + inline void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key, const std::string & Payload) { std::lock_guard G(InfraMutex_); try { Poco::JSON::Parser P; @@ -3512,28 +3504,28 @@ namespace OpenWifi { } - inline void MicroService::handleHelp(const std::string &name, const std::string &value) { + inline void MicroService::handleHelp([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) { HelpRequested_ = true; displayHelp(); stopOptionsProcessing(); } - inline void MicroService::handleVersion(const std::string &name, const std::string &value) { + inline void MicroService::handleVersion([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) { HelpRequested_ = true; std::cout << Version() << std::endl; stopOptionsProcessing(); } - inline void MicroService::handleDebug(const std::string &name, const std::string &value) { + inline void MicroService::handleDebug([[maybe_unused]] const std::string &name, const std::string &value) { if(value == "true") DebugMode_ = true ; } - inline void MicroService::handleLogs(const std::string &name, const std::string &value) { + inline void MicroService::handleLogs([[maybe_unused]] const std::string &name, const std::string &value) { LogDir_ = value; } - inline void MicroService::handleConfig(const std::string &name, const std::string &value) { + inline void MicroService::handleConfig([[maybe_unused]] const std::string &name, const std::string &value) { ConfigFileName_ = value; } @@ -3770,10 +3762,10 @@ namespace OpenWifi { std::unique_ptr NewServer; if(MicroService::instance().NoAPISecurity()) { auto Sock{Svr.CreateSocket(Logger())}; - NewServer = std::make_unique(new ExtRequestHandlerFactory(Server_), Pool_, Sock, Params); + NewServer = std::make_unique(new ExtRequestHandlerFactory, Pool_, Sock, Params); } else { auto Sock{Svr.CreateSecureSocket(Logger())}; - NewServer = std::make_unique(new ExtRequestHandlerFactory(Server_), Pool_, Sock, Params); + NewServer = std::make_unique(new ExtRequestHandlerFactory, Pool_, Sock, Params); }; NewServer->start(); RESTServers_.push_back(std::move(NewServer)); @@ -3806,10 +3798,10 @@ namespace OpenWifi { std::unique_ptr NewServer; if(MicroService::instance().NoAPISecurity()) { auto Sock{Svr.CreateSocket(Logger())}; - NewServer = std::make_unique(new IntRequestHandlerFactory(Server_), Pool_, Sock, Params); + NewServer = std::make_unique(new IntRequestHandlerFactory, Pool_, Sock, Params); } else { auto Sock{Svr.CreateSecureSocket(Logger())}; - NewServer = std::make_unique(new IntRequestHandlerFactory(Server_), Pool_, Sock, Params); + NewServer = std::make_unique(new IntRequestHandlerFactory, Pool_, Sock, Params); }; NewServer->start(); RESTServers_.push_back(std::move(NewServer)); @@ -3818,7 +3810,7 @@ namespace OpenWifi { return 0; } - inline int MicroService::main(const ArgVec &args) { + inline int MicroService::main([[maybe_unused]] const ArgVec &args) { MyErrorHandler ErrorHandler(*this); Poco::ErrorHandler::set(&ErrorHandler); @@ -3864,7 +3856,7 @@ namespace OpenWifi { } } - inline void SubSystemServer::initialize(Poco::Util::Application &self) { + inline void SubSystemServer::initialize([[maybe_unused]] Poco::Util::Application &self) { auto i = 0; bool good = true; @@ -3967,39 +3959,39 @@ namespace OpenWifi { KafkaEnabled_ = MicroService::instance().ConfigGetBool("openwifi.kafka.enable",false); } - inline void KafkaLoggerFun(cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &messqge) { + inline void KafkaLoggerFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &message) { switch ((cppkafka::LogLevel) level) { case cppkafka::LogLevel::LogNotice: { - KafkaManager()->Logger().notice(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); + KafkaManager()->Logger().notice(fmt::format("kafka-log: facility: {} message: {}",facility, message)); } break; case cppkafka::LogLevel::LogDebug: { - KafkaManager()->Logger().debug(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); + KafkaManager()->Logger().debug(fmt::format("kafka-log: facility: {} message: {}",facility, message)); } break; case cppkafka::LogLevel::LogInfo: { - KafkaManager()->Logger().information(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); + KafkaManager()->Logger().information(fmt::format("kafka-log: facility: {} message: {}",facility, message)); } break; case cppkafka::LogLevel::LogWarning: { - KafkaManager()->Logger().warning(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); + KafkaManager()->Logger().warning(fmt::format("kafka-log: facility: {} message: {}",facility, message)); } break; case cppkafka::LogLevel::LogAlert: case cppkafka::LogLevel::LogCrit: { - KafkaManager()->Logger().critical(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); + KafkaManager()->Logger().critical(fmt::format("kafka-log: facility: {} message: {}",facility, message)); } break; case cppkafka::LogLevel::LogErr: case cppkafka::LogLevel::LogEmerg: default: { - KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, messqge)); + KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, message)); } break; } } - inline void KafkaErrorFun(cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) { + inline void KafkaErrorFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) { KafkaManager()->Logger().error(fmt::format("kafka-error: {}, reason: {}", error, reason)); } @@ -4072,13 +4064,13 @@ namespace OpenWifi { Config.set_default_topic_configuration(topic_config); cppkafka::Consumer Consumer(Config); - Consumer.set_assignment_callback([this](cppkafka::TopicPartitionList& partitions) { + Consumer.set_assignment_callback([](cppkafka::TopicPartitionList& partitions) { if(!partitions.empty()) { KafkaManager()->Logger().information(fmt::format("Partition assigned: {}...", partitions.front().get_partition())); } }); - Consumer.set_revocation_callback([this](const cppkafka::TopicPartitionList& partitions) { + Consumer.set_revocation_callback([](const cppkafka::TopicPartitionList& partitions) { if(!partitions.empty()) { KafkaManager()->Logger().information(fmt::format("Partition revocation: {}...", partitions.front().get_partition())); @@ -4119,14 +4111,14 @@ namespace OpenWifi { Consumer.unsubscribe(); } - inline void RESTAPI_ExtServer::reinitialize(Poco::Util::Application &self) { + inline void RESTAPI_ExtServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) { MicroService::instance().LoadConfigurationFile(); Logger().information("Reinitializing."); Stop(); Start(); } - void RESTAPI_IntServer::reinitialize(Poco::Util::Application &self) { + void RESTAPI_IntServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) { MicroService::instance().LoadConfigurationFile(); Logger().information("Reinitializing."); Stop(); diff --git a/src/framework/orm.h b/src/framework/orm.h index 4ffa5b5..717d3ac 100644 --- a/src/framework/orm.h +++ b/src/framework/orm.h @@ -157,7 +157,9 @@ namespace ORM { template class DBCache { public: - DBCache(unsigned Size, unsigned Timeout) + DBCache(unsigned Size, unsigned Timeout) : + Size_(Size), + Timeout_(Timeout) { } @@ -166,7 +168,8 @@ namespace ORM { virtual void UpdateCache(const RecordType &R)=0; virtual void Delete(const std::string &FieldName, const std::string &Value)=0; private: - + size_t Size_=0; + uint64_t Timeout_=0; }; template class DB { @@ -182,8 +185,8 @@ namespace ORM { Poco::Logger &L, const char *Prefix, DBCache * Cache=nullptr): - Type_(dbtype), TableName_(TableName), + Type_(dbtype), Pool_(Pool), Logger_(L), Prefix_(Prefix), @@ -290,7 +293,7 @@ namespace ORM { return std::string("(")+P1 + BOPS[BOP] + P2 +")"; } - std::string OP( bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) { + std::string OP( [[maybe_unused]] bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) { return P1 + BOPS[BOP] + P2 +")"; } @@ -865,19 +868,19 @@ namespace ORM { } protected: + std::string TableName_; + OpenWifi::DBType Type_; Poco::Data::SessionPool &Pool_; Poco::Logger &Logger_; - std::string TableName_; + std::string Prefix_; DBCache *Cache_= nullptr; private: - OpenWifi::DBType Type_; std::string CreateFields_; std::string SelectFields_; std::string SelectList_; std::string UpdateFields_; std::vector IndexCreation_; std::map FieldNames_; - std::string Prefix_; }; } diff --git a/src/sdks/SDK_prov.cpp b/src/sdks/SDK_prov.cpp index 1766552..608ca89 100644 --- a/src/sdks/SDK_prov.cpp +++ b/src/sdks/SDK_prov.cpp @@ -103,7 +103,7 @@ namespace OpenWifi::SDK::Prov { return true; } - bool Update( RESTAPIHandler *client, const std::string &ConfigUUID, ProvObjects::DeviceConfiguration & Config) { + bool Update( [[maybe_unused]] RESTAPIHandler *client, [[maybe_unused]] const std::string &ConfigUUID,[[maybe_unused]] ProvObjects::DeviceConfiguration & Config) { return false; } diff --git a/src/storage/storage_boards.cpp b/src/storage/storage_boards.cpp index 7310db2..051656d 100644 --- a/src/storage/storage_boards.cpp +++ b/src/storage/storage_boards.cpp @@ -33,7 +33,7 @@ namespace OpenWifi { BoardsDB::BoardsDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) : DB(T, "boards", Boards_Fields, BoardsDB_Indexes, P, L, "bor") {} - bool BoardsDB::Upgrade(uint32_t from, uint32_t &to) { + bool BoardsDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { std::vector Statements{ }; RunScript(Statements); diff --git a/src/storage/storage_boards.h b/src/storage/storage_boards.h index 1bc3ef5..302152c 100644 --- a/src/storage/storage_boards.h +++ b/src/storage/storage_boards.h @@ -21,6 +21,7 @@ namespace OpenWifi { class BoardsDB : public ORM::DB { public: BoardsDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~BoardsDB() {}; private: bool Upgrade(uint32_t from, uint32_t &to) override; }; diff --git a/src/storage/storage_timepoints.cpp b/src/storage/storage_timepoints.cpp index b27f19d..55ba2f9 100644 --- a/src/storage/storage_timepoints.cpp +++ b/src/storage/storage_timepoints.cpp @@ -31,7 +31,7 @@ namespace OpenWifi { TimePointDB::TimePointDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) : DB(T, "timepoints", TimePoint_Fields, TimePointDB_Indexes, P, L, "tpo") {} - bool TimePointDB::Upgrade(uint32_t from, uint32_t &to) { + bool TimePointDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { std::vector Statements{ }; RunScript(Statements); diff --git a/src/storage/storage_timepoints.h b/src/storage/storage_timepoints.h index 95ba1f0..5dcbf87 100644 --- a/src/storage/storage_timepoints.h +++ b/src/storage/storage_timepoints.h @@ -23,6 +23,7 @@ namespace OpenWifi { TimePointDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); bool GetStats(const std::string &id, AnalyticsObjects::DeviceTimePointStats &S); bool SelectRecords(const std::string &boardId, uint64_t FromDate, uint64_t LastDate, uint64_t MaxRecords, DB::RecordVec & Recs); + virtual ~TimePointDB() {}; private: bool Upgrade(uint32_t from, uint32_t &to) override; };