diff --git a/CMakeLists.txt b/CMakeLists.txt index 23b2b51..a7bcba5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,10 @@ include_directories(/usr/local/include /usr/local/opt/openssl/include src inclu configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY) +add_compile_options(-Wall -Wextra) +#add_compile_options(-fsanitize=address) +#add_link_options(-fsanitize=address) + add_executable(owprov build src/ow_version.h.in diff --git a/build b/build index d1cbcfa..2fb681e 100644 --- a/build +++ b/build @@ -1 +1 @@ -66 \ No newline at end of file +71 \ No newline at end of file diff --git a/src/APConfig.cpp b/src/APConfig.cpp index 6e782ee..6473da2 100644 --- a/src/APConfig.cpp +++ b/src/APConfig.cpp @@ -37,7 +37,7 @@ namespace OpenWifi { return false; } - static void ShowJSON(const char *S, const Poco::JSON::Object::Ptr &Obj) { + static void ShowJSON([[maybe_unused]] const char *S, [[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) { /* std::stringstream O; Poco::JSON::Stringifier::stringify(Obj,O); @@ -286,7 +286,7 @@ namespace OpenWifi { } else { // we need to insert after everything bigger or equal auto Hint = std::lower_bound(Config_.cbegin(),Config_.cend(),i.weight, - [](const VerboseElement &Elem, int Value) { + [](const VerboseElement &Elem, uint64_t Value) { return Elem.element.weight>=Value; }); VerboseElement VE{ .element = i, .info = Config.info}; Config_.insert(Hint,VE); diff --git a/src/ConfigSanityChecker.cpp b/src/ConfigSanityChecker.cpp index 8dcc45e..88a9423 100644 --- a/src/ConfigSanityChecker.cpp +++ b/src/ConfigSanityChecker.cpp @@ -25,27 +25,27 @@ namespace OpenWifi { return false; } - void ConfigSanityChecker::Check_radios(nlohmann::json &d) { + void ConfigSanityChecker::Check_radios([[maybe_unused]] nlohmann::json &d) { std::cout << "Validating radios" << std::endl; }; - void ConfigSanityChecker::Check_interfaces(nlohmann::json &d) { + void ConfigSanityChecker::Check_interfaces([[maybe_unused]] nlohmann::json &d) { std::cout << "Validating interfaces" << std::endl; }; - void ConfigSanityChecker::Check_metrics(nlohmann::json &d) { + void ConfigSanityChecker::Check_metrics([[maybe_unused]] nlohmann::json &d) { std::cout << "Validating metrics" << std::endl; }; - void ConfigSanityChecker::Check_services(nlohmann::json &d) { + void ConfigSanityChecker::Check_services([[maybe_unused]] nlohmann::json &d) { std::cout << "Validating services" << std::endl; }; - void ConfigSanityChecker::Check_uuid(nlohmann::json &d) { + void ConfigSanityChecker::Check_uuid([[maybe_unused]] nlohmann::json &d) { std::cout << "Validating uuid" << std::endl; }; diff --git a/src/Daemon.cpp b/src/Daemon.cpp index 19f6627..d70ea52 100644 --- a/src/Daemon.cpp +++ b/src/Daemon.cpp @@ -48,7 +48,7 @@ namespace OpenWifi { return instance_; } - void Daemon::initialize() { + void Daemon::PostInitialization([[maybe_unused]] Poco::Util::Application &self) { if(MicroService::instance().ConfigGetBool("firmware.updater.upgrade",false)) { if(MicroService::instance().ConfigGetBool("firmware.updater.releaseonly",false)) { FWRules_ = ProvObjects::upgrade_release_only; @@ -69,10 +69,6 @@ namespace OpenWifi { } } } - - void MicroServicePostInitialization() { - Daemon()->initialize(); - } } int main(int argc, char **argv) { diff --git a/src/Daemon.h b/src/Daemon.h index dcbe846..6e601f9 100644 --- a/src/Daemon.h +++ b/src/Daemon.h @@ -37,12 +37,13 @@ namespace OpenWifi { const SubSystemVec & SubSystems) : MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {}; - void initialize(); static Daemon *instance(); inline OpenWifi::ProvisioningDashboard & GetDashboard() { return DB_; } Poco::Logger & Log() { return Poco::Logger::get(AppName()); } ProvObjects::FIRMWARE_UPGRADE_RULES FirmwareRules() const { return FWRules_; } inline const std::string & AssetDir() { return AssetDir_; } + void PostInitialization(Poco::Util::Application &self); + private: static Daemon *instance_; OpenWifi::ProvisioningDashboard DB_{}; @@ -51,5 +52,7 @@ namespace OpenWifi { }; inline Daemon * Daemon() { return Daemon::instance(); } -} + inline void DaemonPostInitialization(Poco::Util::Application &self) { + Daemon()->PostInitialization(self); + }} diff --git a/src/DeviceTypeCache.h b/src/DeviceTypeCache.h index 6ed11f4..242a9b5 100644 --- a/src/DeviceTypeCache.h +++ b/src/DeviceTypeCache.h @@ -31,7 +31,7 @@ namespace OpenWifi { Timer_.stop(); } - inline void onTimer(Poco::Timer & timer) { + inline void onTimer([[maybe_unused]] Poco::Timer & timer) { UpdateDeviceTypes(); } diff --git a/src/FileDownloader.cpp b/src/FileDownloader.cpp index 291a6a0..4c301e2 100644 --- a/src/FileDownloader.cpp +++ b/src/FileDownloader.cpp @@ -19,7 +19,7 @@ namespace OpenWifi { Logger().notice("Stopping."); } - void FileDownloader::onTimer(Poco::Timer &timer) { + void FileDownloader::onTimer([[maybe_unused]] Poco::Timer &timer) { const static std::vector> Files { {"https://raw.githubusercontent.com/blogic/ucentral-schema/main/ucentral.schema.json", "ucentral.schema.json" }, diff --git a/src/JobController.h b/src/JobController.h index 1e67922..0d64ba6 100644 --- a/src/JobController.h +++ b/src/JobController.h @@ -73,7 +73,7 @@ namespace OpenWifi { std::string Description_; std::string RegisteredName_; ParametersVec Parameters_; - bool Parallel_=true; + [[maybe_unused]] bool Parallel_=true; }; class JobRegistry { diff --git a/src/RESTAPI/RESTAPI_map_handler.cpp b/src/RESTAPI/RESTAPI_map_handler.cpp index 7ec2592..48ed6f0 100644 --- a/src/RESTAPI/RESTAPI_map_handler.cpp +++ b/src/RESTAPI/RESTAPI_map_handler.cpp @@ -45,7 +45,7 @@ namespace OpenWifi{ return OK(); } - static auto ValidateVisibility(const std::string &V) { + static bool ValidateVisibility(const std::string &V) { return (V=="private" || V=="public" || V=="select"); } @@ -65,6 +65,10 @@ namespace OpenWifi{ return BadRequest( RESTAPI::Errors::NameMustBeSet); } + if(!ValidateVisibility(NewObject.visibility)) { + return BadRequest("Invalid visibility attribute"); + } + if(RawObject->has("entity")) { if(!NewObject.entity.empty() && !StorageService()->EntityDB().Exists("id",NewObject.entity)) return BadRequest(RESTAPI::Errors::EntityMustExist); @@ -108,10 +112,10 @@ namespace OpenWifi{ } if(Existing.creator != UserInfo_.userinfo.id) { - if(Existing.visibility == ProvObjects::PRIVATE) { + if(Existing.visibility == "private") { return UnAuthorized(RESTAPI::Errors::InsufficientAccessRights, ACCESS_DENIED); } - if(Existing.visibility == ProvObjects::SELECT) { + if(Existing.visibility == "select") { for(const auto &i:Existing.access.list) { for(const auto &j:i.users.list) { if(j==UserInfo_.userinfo.id) { diff --git a/src/RESTAPI/RESTAPI_webSocketServer.cpp b/src/RESTAPI/RESTAPI_webSocketServer.cpp index 55d1f53..43453f0 100644 --- a/src/RESTAPI/RESTAPI_webSocketServer.cpp +++ b/src/RESTAPI/RESTAPI_webSocketServer.cpp @@ -140,9 +140,6 @@ namespace OpenWifi { auto Command = O->get("command").toString(); if (Command == "serial_number_search" && O->has("serial_prefix")) { auto Prefix = O->get("serial_prefix").toString(); - uint64_t HowMany = 32; - if (O->has("howMany")) - HowMany = O->get("howMany"); Logger().information(Poco::format("serial_number_search: %s", Prefix)); if (!Prefix.empty() && Prefix.length() < 13) { std::vector Numbers; diff --git a/src/RESTObjects/RESTAPI_FMSObjects.cpp b/src/RESTObjects/RESTAPI_FMSObjects.cpp index f5de1a1..d5152a6 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..79967c9 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.cpp +++ b/src/RESTObjects/RESTAPI_ProvObjects.cpp @@ -626,7 +626,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_to_json( Obj,"data",data); RESTAPI_utils::field_to_json( Obj,"entity",entity); RESTAPI_utils::field_to_json( Obj,"creator",creator); - field_to_json( Obj,"visibility",visibility); + RESTAPI_utils::field_to_json( Obj,"visibility",visibility); RESTAPI_utils::field_to_json( Obj,"access",access); RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy); RESTAPI_utils::field_to_json( Obj,"venue", venue); @@ -638,7 +638,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_from_json( Obj,"data",data); RESTAPI_utils::field_from_json( Obj,"entity",entity); RESTAPI_utils::field_from_json( Obj,"creator",creator); - field_from_json( Obj,"visibility",visibility); + RESTAPI_utils::field_from_json( Obj,"visibility",visibility); RESTAPI_utils::field_from_json( Obj,"access",access); RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy); RESTAPI_utils::field_from_json( Obj,"venue", venue); @@ -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/RESTObjects/RESTAPI_ProvObjects.h b/src/RESTObjects/RESTAPI_ProvObjects.h index ce56234..09b3b63 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.h +++ b/src/RESTObjects/RESTAPI_ProvObjects.h @@ -400,7 +400,7 @@ namespace OpenWifi::ProvObjects { std::string data; std::string entity; std::string creator; - VISIBILITY visibility = PRIVATE; + std::string visibility{"private"}; ObjectACLList access; Types::UUID_t managementPolicy; std::string venue; diff --git a/src/SerialNumberCache.h b/src/SerialNumberCache.h index d896b1f..4d027c4 100644 --- a/src/SerialNumberCache.h +++ b/src/SerialNumberCache.h @@ -37,7 +37,7 @@ namespace OpenWifi { private: int DeviceTypeIndex_=0; - uint64_t LastUpdate_ = 0 ; + [[maybe_unused]] uint64_t LastUpdate_ = 0 ; SerialCacheContent SNs_; std::map DeviceTypeDictionary_; diff --git a/src/Signup.cpp b/src/Signup.cpp index 58a1370..1254828 100644 --- a/src/Signup.cpp +++ b/src/Signup.cpp @@ -35,7 +35,7 @@ namespace OpenWifi { Worker_.join(); } - void Signup::onTimer(Poco::Timer &timer) { + void Signup::onTimer([[maybe_unused]] Poco::Timer &timer) { std::lock_guard G(Mutex_); StorageService()->SignupDB().RemoveIncompleteSignups(); } diff --git a/src/StorageService.cpp b/src/StorageService.cpp index 07bb06f..e82c8a9 100644 --- a/src/StorageService.cpp +++ b/src/StorageService.cpp @@ -66,11 +66,11 @@ namespace OpenWifi { ExpandFunc_[ConfigurationDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return ConfigurationDB_->GetNameAndDescription(F,V, Name, Description); }; ExpandFunc_[LocationDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return LocationDB_->GetNameAndDescription(F,V, Name, Description); }; ExpandFunc_[RolesDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return RolesDB_->GetNameAndDescription(F,V, Name, Description); }; - ExpandFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsDictionaryDB_->Exists(F,V); }; - ExpandFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsObjectDB_->Exists(F,V);; }; - ExpandFunc_[MapDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return MapDB_->Exists(F,V);; }; - ExpandFunc_[SignupDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return SignupDB_->Exists(F,V);; }; - ExpandFunc_[VariablesDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return VariablesDB_->Exists(F,V);; }; + ExpandFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return TagsDictionaryDB_->Exists(F,V); }; + ExpandFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return TagsObjectDB_->Exists(F,V);; }; + ExpandFunc_[MapDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return MapDB_->Exists(F,V);; }; + ExpandFunc_[SignupDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return SignupDB_->Exists(F,V);; }; + ExpandFunc_[VariablesDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return VariablesDB_->Exists(F,V);; }; EntityDB_->CheckForRoot(); InventoryDB_->InitializeSerialCache(); @@ -82,7 +82,7 @@ namespace OpenWifi { return 0; } - void Storage::onTimer(Poco::Timer &timer) { + void Storage::onTimer([[maybe_unused]] Poco::Timer &timer) { } void Storage::Stop() { diff --git a/src/TagServer.cpp b/src/TagServer.cpp index f47c43a..46e0e9b 100644 --- a/src/TagServer.cpp +++ b/src/TagServer.cpp @@ -10,7 +10,7 @@ namespace OpenWifi { // we need to get the entire dictionary in memory... // std::function Function = [](const TagsDictionary &D) -> bool { return true; }; - StorageService()->TagsDictionaryDB().Iterate([](const TagsDictionary &D) -> bool { return true; }); + StorageService()->TagsDictionaryDB().Iterate([]([[maybe_unused]] const TagsDictionary &D) -> bool { return true; }); return 0; diff --git a/src/WebSocketClientServer.cpp b/src/WebSocketClientServer.cpp index 15d4c2a..92e9e11 100644 --- a/src/WebSocketClientServer.cpp +++ b/src/WebSocketClientServer.cpp @@ -32,7 +32,7 @@ namespace OpenWifi { } }; - void WebSocketClient::OnSocketError(const Poco::AutoPtr &pNf) { + void WebSocketClient::OnSocketError([[maybe_unused]] const Poco::AutoPtr &pNf) { delete this; } @@ -45,7 +45,7 @@ namespace OpenWifi { return false; } - void WebSocketClient::OnSocketReadable(const Poco::AutoPtr &pNf) { + void WebSocketClient::OnSocketReadable([[maybe_unused]] const Poco::AutoPtr &pNf) { int flags; int n; bool Done=false; @@ -96,7 +96,7 @@ namespace OpenWifi { std::string Answer; Process(Obj, Answer, Done ); if (!Answer.empty()) - WS_->sendFrame(Answer.c_str(), Answer.size()); + WS_->sendFrame(Answer.c_str(), (int) Answer.size()); else { WS_->sendFrame("{}", 2); } @@ -117,7 +117,7 @@ namespace OpenWifi { } } - void WebSocketClient::OnSocketShutdown(const Poco::AutoPtr &pNf) { + void WebSocketClient::OnSocketShutdown([[maybe_unused]] const Poco::AutoPtr &pNf) { delete this; } @@ -127,9 +127,6 @@ namespace OpenWifi { auto Command = O->get("command").toString(); if (Command == "serial_number_search" && O->has("serial_prefix")) { auto Prefix = O->get("serial_prefix").toString(); - uint64_t HowMany = 32; - if (O->has("howMany")) - HowMany = O->get("howMany"); Logger().information(Poco::format("serial_number_search: %s", Prefix)); if (!Prefix.empty() && Prefix.length() < 13) { std::vector Numbers; diff --git a/src/WebSocketClientServer.h b/src/WebSocketClientServer.h index 9ce4d4c..da06677 100644 --- a/src/WebSocketClientServer.h +++ b/src/WebSocketClientServer.h @@ -17,17 +17,17 @@ namespace OpenWifi { class MyParallelSocketReactor { public: - explicit MyParallelSocketReactor(unsigned NumReactors=8) : + explicit MyParallelSocketReactor(uint32_t NumReactors=8) : NumReactors_(NumReactors) { Reactors_ = new Poco::Net::SocketReactor[NumReactors_]; - for(int i=0;i(); - for (auto const i : *Object) { + for (auto const &i : *Object) { auto InnerObject = i.template extract(); T Obj; Obj.from_json(InnerObject); @@ -751,15 +749,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; @@ -851,7 +846,7 @@ namespace OpenWifi::Utils { inline bool ParseTime(const std::string &Time, int & Hours, int & Minutes, int & Seconds) { Poco::StringTokenizer TimeTokens(Time,":",Poco::StringTokenizer::TOK_TRIM); - Hours = Minutes = Hours = 0 ; + Hours = Minutes = Seconds = 0 ; if(TimeTokens.count()==1) { Hours = std::atoi(TimeTokens[0].c_str()); } else if(TimeTokens.count()==2) { @@ -1257,7 +1252,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 +1277,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 +1298,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 +1398,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 +1536,7 @@ namespace OpenWifi { private: std::string address_; + uint32_t port_; std::string cert_file_; std::string key_file_; std::string root_ca_; @@ -1539,7 +1544,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 +1557,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 +1579,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 +1780,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 +1858,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); @@ -1938,13 +1942,13 @@ namespace OpenWifi { [[nodiscard]] inline static std::string MakeList(const std::vector &L) { std::string Return; - for (const auto &i : L) - if (Return.empty()) - Return = i; - else - Return += ", " + i; - - return Return; + for (const auto &i : L) { + if (Return.empty()) + Return = i; + else + Return += ", " + i; + } + return Return; } static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, Types::UUIDvec_t & Value) { @@ -2138,7 +2142,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); @@ -2243,8 +2247,9 @@ namespace OpenWifi { auto RawSelect = GetParameter(RESTAPI::Protocol::SELECT, ""); auto Entries = Poco::StringTokenizer(RawSelect,","); - for(const auto &i:Entries) + for(const auto &i:Entries) { QB_.Select.emplace_back(i); + } if(QB_.Offset<1) QB_.Offset=0; return true; @@ -2640,7 +2645,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 +2717,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 +2915,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 +2973,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 +3035,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 +3043,6 @@ namespace OpenWifi { } private: static inline std::atomic_uint64_t TransactionId_ = 1; - Poco::Logger &Logger_; - RESTAPI_GenericServer &Server_; }; struct MicroServiceMeta { @@ -3198,7 +3189,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 +3207,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 +3217,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; @@ -3425,8 +3416,11 @@ namespace OpenWifi { } } + void DaemonPostInitialization(Poco::Util::Application &self); + inline void MicroService::initialize(Poco::Util::Application &self) { // add the default services + std::cout << "Initialize MicroService" << std::endl; LoadConfigurationFile(); InitializeLoggingSystem(); @@ -3458,11 +3452,10 @@ namespace OpenWifi { InitializeSubSystemServers(); ServerApplication::initialize(self); + DaemonPostInitialization(self); Types::TopicNotifyFunction F = [this](const std::string &Key,const std::string &Payload) { this->BusMessageReceived(Key, Payload); }; KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F); - - MicroServicePostInitialization(); } inline void MicroService::uninitialize() { @@ -3512,28 +3505,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; } @@ -3688,14 +3681,16 @@ namespace OpenWifi { } inline std::string MicroService::Encrypt(const std::string &S) { - if(NoBuiltInCrypto_) + if(NoBuiltInCrypto_) { return S; + } return Cipher_->encryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);; } inline std::string MicroService::Decrypt(const std::string &S) { - if(NoBuiltInCrypto_) + if(NoBuiltInCrypto_) { return S; + } return Cipher_->decryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);; } @@ -3770,10 +3765,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 +3801,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 +3813,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 +3859,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 +3962,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 +4067,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 +4114,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..f38dcc3 100644 --- a/src/framework/orm.h +++ b/src/framework/orm.h @@ -108,11 +108,11 @@ namespace ORM { return "LONGBLOB"; else if(Type==OpenWifi::DBType::pgsql) return "BYTEA"; - else if(Type==OpenWifi::DBType::sqlite) + else return "BLOB"; - default: - assert(false); - return ""; + default: + assert(false); + } assert(false); return ""; @@ -121,12 +121,13 @@ namespace ORM { inline std::string Escape(const std::string &S) { std::string R; - for(const auto &i:S) - if(i=='\'') + for(const auto &i:S) { + if (i == '\'') R += "''"; else R += i; - return R; + } + return R; } enum SqlComparison { EQ = 0, NEQ, LT, LTE, GT, GTE }; @@ -157,7 +158,9 @@ namespace ORM { template class DBCache { public: - DBCache(unsigned Size, unsigned Timeout) + DBCache(unsigned Size, unsigned Timeout) : + Size_(Size), + Timeout_(Timeout) { } @@ -166,7 +169,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 +186,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 +294,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 +869,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/framework/ow_constants.h b/src/framework/ow_constants.h index d9833e0..14ebc11 100644 --- a/src/framework/ow_constants.h +++ b/src/framework/ow_constants.h @@ -7,6 +7,16 @@ #include #include "Poco/String.h" +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#endif + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-variable" +#endif + namespace OpenWifi::RESTAPI::Errors { static const std::string MissingUUID{"Missing UUID."}; static const std::string MissingSerialNumber{"Missing Serial Number."}; @@ -353,4 +363,12 @@ namespace OpenWifi::Provisioning::DeviceClass { } +#if defined(__GNUC__ ) +#pragma GCC diagnostic pop +#endif + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + diff --git a/src/sdks/SDK_gw.cpp b/src/sdks/SDK_gw.cpp index a26873d..6dc82fe 100644 --- a/src/sdks/SDK_gw.cpp +++ b/src/sdks/SDK_gw.cpp @@ -8,7 +8,7 @@ namespace OpenWifi::SDK::GW { namespace Device { - void Reboot(RESTAPIHandler *client, const std::string & Mac, uint64_t When) { + void Reboot(RESTAPIHandler *client, const std::string & Mac, [[maybe_unused]] uint64_t When) { std::string EndPoint = "/api/v1/device/" + Mac + "/reboot"; Poco::JSON::Object ObjRequest; @@ -40,7 +40,7 @@ namespace OpenWifi::SDK::GW { PerformCommand(client,"factory",EndPoint, ObjRequest); } - void Upgrade(RESTAPIHandler *client, const std::string & Mac, uint64_t When, const std::string & ImageName, bool KeepRedirector) { + void Upgrade(RESTAPIHandler *client, const std::string & Mac, uint64_t When, const std::string & ImageName, [[maybe_unused]] bool KeepRedirector) { std::string EndPoint = "/api/v1/device/" + Mac + "/upgrade"; Poco::JSON::Object ObjRequest; diff --git a/src/sdks/SDK_prov.cpp b/src/sdks/SDK_prov.cpp index bd6dc02..63a4866 100644 --- a/src/sdks/SDK_prov.cpp +++ b/src/sdks/SDK_prov.cpp @@ -82,7 +82,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/sdks/SDK_sec.cpp b/src/sdks/SDK_sec.cpp index 9fe37d5..fcc37eb 100644 --- a/src/sdks/SDK_sec.cpp +++ b/src/sdks/SDK_sec.cpp @@ -7,7 +7,7 @@ namespace OpenWifi::SDK::Sec { namespace User { - bool Exists(RESTAPIHandler *client, const Types::UUID_t & Id) { + bool Exists([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id) { OpenAPIRequestGet Req( uSERVICE_SECURITY, "/api/v1/user/" + Id, {}, @@ -21,7 +21,7 @@ namespace OpenWifi::SDK::Sec { return false; } - bool Get(RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) { + bool Get([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) { OpenAPIRequestGet Req( uSERVICE_SECURITY, "/api/v1/user/" + Id, {}, @@ -37,7 +37,7 @@ namespace OpenWifi::SDK::Sec { } namespace Subscriber { - bool Exists(RESTAPIHandler *client, const Types::UUID_t & Id) { + bool Exists([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id) { OpenAPIRequestGet Req( uSERVICE_SECURITY, "/api/v1/subuser/" + Id, {}, @@ -51,7 +51,7 @@ namespace OpenWifi::SDK::Sec { return false; } - bool Get(RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) { + bool Get([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) { OpenAPIRequestGet Req( uSERVICE_SECURITY, "/api/v1/subuser/" + Id, {}, @@ -65,7 +65,7 @@ namespace OpenWifi::SDK::Sec { return false; } - bool Delete(RESTAPIHandler *client, const Types::UUID_t & Id) { + bool Delete([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id) { OpenAPIRequestDelete Req( uSERVICE_SECURITY, "/api/v1/subuser/" + Id, {}, diff --git a/src/storage/storage_configurations.cpp b/src/storage/storage_configurations.cpp index 1672991..3c2a742 100644 --- a/src/storage/storage_configurations.cpp +++ b/src/storage/storage_configurations.cpp @@ -45,7 +45,7 @@ namespace OpenWifi { ORM::Indextype::ASC} } } }; - bool ConfigurationDB::Upgrade(uint32_t from, uint32_t &to) { + bool ConfigurationDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { std::vector Statements{ "alter table " + TableName_ + " add column subscriberOnly BOOLEAN;", "alter table " + TableName_ + " add column entity TEXT;", diff --git a/src/storage/storage_configurations.h b/src/storage/storage_configurations.h index 012bc79..534e7bb 100644 --- a/src/storage/storage_configurations.h +++ b/src/storage/storage_configurations.h @@ -39,6 +39,7 @@ namespace OpenWifi { ConfigurationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); bool GetListOfAffectedDevices(const Types::UUID_t & ConfigUUID, Types::UUIDvec_t & DeviceSerialNumbers ); bool Upgrade(uint32_t from, uint32_t &to) override; + virtual ~ConfigurationDB() {}; private: }; } diff --git a/src/storage/storage_contact.h b/src/storage/storage_contact.h index fca40a4..ff36527 100644 --- a/src/storage/storage_contact.h +++ b/src/storage/storage_contact.h @@ -40,6 +40,7 @@ namespace OpenWifi { class ContactDB : public ORM::DB { public: ContactDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~ContactDB() {}; private: }; } diff --git a/src/storage/storage_entity.cpp b/src/storage/storage_entity.cpp index d1297ca..8b48729 100644 --- a/src/storage/storage_entity.cpp +++ b/src/storage/storage_entity.cpp @@ -55,7 +55,7 @@ namespace OpenWifi { CheckForRoot(); } - bool EntityDB::Upgrade(uint32_t from, uint32_t &to) { + bool EntityDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { to = Version(); std::vector Script{ "alter table " + TableName_ + " add column variables text", diff --git a/src/storage/storage_entity.h b/src/storage/storage_entity.h index 39cca97..9636a9b 100644 --- a/src/storage/storage_entity.h +++ b/src/storage/storage_entity.h @@ -42,6 +42,7 @@ namespace OpenWifi { public: static const std::string RootUUID_; EntityDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~EntityDB() {}; inline bool RootExists() const { return RootExists_; }; static inline bool IsRoot(const std::string &UUID) { return (UUID == RootUUID_); } static inline const std::string RootUUID() { return RootUUID_; } diff --git a/src/storage/storage_inventory.cpp b/src/storage/storage_inventory.cpp index 9be698a..7c6c08c 100644 --- a/src/storage/storage_inventory.cpp +++ b/src/storage/storage_inventory.cpp @@ -57,7 +57,7 @@ namespace OpenWifi { ORM::Indextype::ASC} } } }; - bool InventoryDB::Upgrade(uint32_t from, uint32_t &to) { + bool InventoryDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { to = Version(); std::vector Script{ "alter table " + TableName_ + " add column state text" , diff --git a/src/storage/storage_inventory.h b/src/storage/storage_inventory.h index bed4805..f53eaca 100644 --- a/src/storage/storage_inventory.h +++ b/src/storage/storage_inventory.h @@ -41,6 +41,7 @@ namespace OpenWifi { class InventoryDB : public ORM::DB { public: InventoryDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~InventoryDB() {}; bool CreateFromConnection(const std::string & SerialNumber, const std::string & ConnectionInfo, const std::string & DeviceType, const std::string &Locale ); bool FindFirmwareOptions(std::string & SerialNumber, ProvObjects::FIRMWARE_UPGRADE_RULES & Rules); diff --git a/src/storage/storage_jobs.h b/src/storage/storage_jobs.h index 3a661b4..18d3090 100644 --- a/src/storage/storage_jobs.h +++ b/src/storage/storage_jobs.h @@ -34,6 +34,7 @@ namespace OpenWifi { class JobDB : public ORM::DB { public: JobDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~JobDB() {}; private: }; } diff --git a/src/storage/storage_location.h b/src/storage/storage_location.h index bc2ecf4..efb8a63 100644 --- a/src/storage/storage_location.h +++ b/src/storage/storage_location.h @@ -38,6 +38,7 @@ namespace OpenWifi { class LocationDB : public ORM::DB { public: LocationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~LocationDB() {}; private: }; } diff --git a/src/storage/storage_management_roles.cpp b/src/storage/storage_management_roles.cpp index 3961f06..9b02fdc 100644 --- a/src/storage/storage_management_roles.cpp +++ b/src/storage/storage_management_roles.cpp @@ -40,7 +40,7 @@ namespace OpenWifi { ManagementRoleDB::ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) : DB(T, "roles", RolesDB_Fields, RolesDB_Indexes, P, L, "rol") {} - bool ManagementRoleDB::Upgrade(uint32_t from, uint32_t &to) { + bool ManagementRoleDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { std::vector Statements{ "alter table " + TableName_ + " add column entity text;", "alter table " + TableName_ + " add column venue text;" diff --git a/src/storage/storage_management_roles.h b/src/storage/storage_management_roles.h index a455325..ed4b916 100644 --- a/src/storage/storage_management_roles.h +++ b/src/storage/storage_management_roles.h @@ -30,6 +30,7 @@ namespace OpenWifi { class ManagementRoleDB : public ORM::DB { public: ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~ManagementRoleDB() {}; private: bool Upgrade(uint32_t from, uint32_t &to) override; }; diff --git a/src/storage/storage_maps.cpp b/src/storage/storage_maps.cpp index a0d5500..fe224a5 100644 --- a/src/storage/storage_maps.cpp +++ b/src/storage/storage_maps.cpp @@ -34,7 +34,7 @@ namespace OpenWifi { MapDB::MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) : DB(T, "maps", MapsDB_Fields, MapsDB_Indexes, P, L, "map") {} - bool MapDB::Upgrade(uint32_t from, uint32_t &to) { + bool MapDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { std::vector Statements{ "alter table " + TableName_ + " add column managementPolicy text;", "alter table " + TableName_ + " add column entity text;", @@ -57,7 +57,7 @@ template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Ma Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<6>()); Out.data = In.get<7>(); Out.creator = In.get<8>(); - Out.visibility = OpenWifi::ProvObjects::visibility_from_string(In.get<9>()); + Out.visibility = In.get<9>(); Out.access = OpenWifi::RESTAPI_utils::to_object(In.get<10>()); Out.entity = In.get<11>(); Out.managementPolicy = In.get<12>(); @@ -74,7 +74,7 @@ template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Ma Out.set<6>(OpenWifi::RESTAPI_utils::to_string(In.info.tags)); Out.set<7>(In.data); Out.set<8>(In.creator); - Out.set<9>(OpenWifi::ProvObjects::to_string(In.visibility)); + Out.set<9>(In.visibility); Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.access)); Out.set<11>(In.entity); Out.set<12>(In.managementPolicy); diff --git a/src/storage/storage_maps.h b/src/storage/storage_maps.h index 81bdb18..6c421d9 100644 --- a/src/storage/storage_maps.h +++ b/src/storage/storage_maps.h @@ -28,6 +28,7 @@ namespace OpenWifi { class MapDB : public ORM::DB { public: MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~MapDB() {}; private: bool Upgrade(uint32_t from, uint32_t &to) override; }; diff --git a/src/storage/storage_policies.cpp b/src/storage/storage_policies.cpp index d9b70f9..cda5de2 100644 --- a/src/storage/storage_policies.cpp +++ b/src/storage/storage_policies.cpp @@ -38,7 +38,7 @@ namespace OpenWifi { PolicyDB::PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) : DB(T, "policies", PolicyDB_Fields, PolicyDB_Indexes, P, L, "pol") {} - bool PolicyDB::Upgrade(uint32_t from, uint32_t &to) { + bool PolicyDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { std::vector Statements{ "alter table " + TableName_ + " add column entity text;", "alter table " + TableName_ + " add column venue text;" diff --git a/src/storage/storage_policies.h b/src/storage/storage_policies.h index 54880ef..c802f31 100644 --- a/src/storage/storage_policies.h +++ b/src/storage/storage_policies.h @@ -29,6 +29,7 @@ namespace OpenWifi { class PolicyDB : public ORM::DB { public: PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~PolicyDB() {}; private: bool Upgrade(uint32_t from, uint32_t &to) override; }; diff --git a/src/storage/storage_signup.h b/src/storage/storage_signup.h index 8722946..fe5ffb2 100644 --- a/src/storage/storage_signup.h +++ b/src/storage/storage_signup.h @@ -30,6 +30,7 @@ namespace OpenWifi { class SignupDB : public ORM::DB { public: explicit SignupDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) noexcept; + virtual ~SignupDB() {}; bool GetIncompleteSignups( SignupDB::RecordVec & Signups ); void RemoveIncompleteSignups(); private: diff --git a/src/storage/storage_tags.cpp b/src/storage/storage_tags.cpp index e3bb37f..ee86a6a 100644 --- a/src/storage/storage_tags.cpp +++ b/src/storage/storage_tags.cpp @@ -14,7 +14,7 @@ namespace OpenWifi { // object info ORM::Field{"entity",ORM::FieldType::FT_TEXT, 64}, ORM::Field{"id",ORM::FieldType::FT_INT, 0,true}, - ORM::Field{"name",ORM::FieldType::FT_TEXT, 32, } + ORM::Field{"name",ORM::FieldType::FT_TEXT, 32} }; static ORM::IndexVec TagsDictionaryDB_Indexes{ diff --git a/src/storage/storage_tags.h b/src/storage/storage_tags.h index eff29b4..ba78a67 100644 --- a/src/storage/storage_tags.h +++ b/src/storage/storage_tags.h @@ -35,12 +35,14 @@ namespace OpenWifi { class TagsDictionaryDB : public ORM::DB { public: TagsDictionaryDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~TagsDictionaryDB() {}; private: }; class TagsObjectDB : public ORM::DB { public: TagsObjectDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~TagsObjectDB() {}; private: }; } diff --git a/src/storage/storage_variables.cpp b/src/storage/storage_variables.cpp index e0f7478..fc10f49 100644 --- a/src/storage/storage_variables.cpp +++ b/src/storage/storage_variables.cpp @@ -42,7 +42,7 @@ namespace OpenWifi { DB(T, "variables2", VariablesDB_Fields, VariablesDB_Indexes, P, L, "var") { } - bool VariablesDB::Upgrade(uint32_t from, uint32_t &to) { + bool VariablesDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { std::vector Statements{ // "alter table " + TableName_ + " add column configurations TEXT;" , // "alter table " + TableName_ + " add column managementPolicy TEXT;" diff --git a/src/storage/storage_variables.h b/src/storage/storage_variables.h index 933b3ba..3df9615 100644 --- a/src/storage/storage_variables.h +++ b/src/storage/storage_variables.h @@ -27,6 +27,7 @@ namespace OpenWifi { class VariablesDB : public ORM::DB { public: explicit VariablesDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) noexcept; + virtual ~VariablesDB() {}; private: bool Upgrade(uint32_t from, uint32_t &to) override; }; diff --git a/src/storage/storage_venue.cpp b/src/storage/storage_venue.cpp index 44e8ac6..240537d 100644 --- a/src/storage/storage_venue.cpp +++ b/src/storage/storage_venue.cpp @@ -55,7 +55,7 @@ namespace OpenWifi { VenueDB::VenueDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) : DB(T, "venues", VenueDB_Fields, VenueDB_Indexes, P, L, "ven") {} - bool VenueDB::Upgrade(uint32_t from, uint32_t &to) { + bool VenueDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) { to = Version(); std::vector Script{ "alter table " + TableName_ + " add column variables text", diff --git a/src/storage/storage_venue.h b/src/storage/storage_venue.h index 1128086..8b9a979 100644 --- a/src/storage/storage_venue.h +++ b/src/storage/storage_venue.h @@ -43,6 +43,7 @@ namespace OpenWifi { class VenueDB : public ORM::DB { public: VenueDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L); + virtual ~VenueDB() {}; bool GetByIP(const std::string &IP, std::string & uuid); bool Upgrade(uint32_t from, uint32_t &to) override; private: