Skip to content

Commit

Permalink
fix: address compiler warnings (clang)
Browse files Browse the repository at this point in the history
Signed-off-by: James Chapman <james.chapman@pionix.de>
  • Loading branch information
james-ctc committed Nov 5, 2024
1 parent db20357 commit f152d40
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 24 deletions.
2 changes: 0 additions & 2 deletions include/utils/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const static std::regex type_uri_regex{R"(^((?:\/[a-zA-Z0-9\-\_]+)+#\/[a-zA-Z0-9
class Config {
private:
std::shared_ptr<RuntimeSettings> rs;
bool manager;

json main;

json manifests;
Expand Down
6 changes: 3 additions & 3 deletions include/utils/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ struct Error {
Error();
ErrorType type;
ErrorSubType sub_type;
std::string description;
std::string message;
Severity severity;
std::string description;
ImplementationIdentifier origin;
std::string vendor_id;
Severity severity;
time_point timestamp;
UUID uuid;
State state;
std::string vendor_id;
};

using ErrorHandle = UUID;
Expand Down
1 change: 1 addition & 0 deletions include/utils/error/error_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ErrorDatabase {
using EditErrorFunc = std::function<void(ErrorPtr)>;

ErrorDatabase() = default;
virtual ~ErrorDatabase() = default;

virtual void add_error(ErrorPtr error) = 0;
virtual std::list<ErrorPtr> get_errors(const std::list<ErrorFilter>& filters) const = 0;
Expand Down
4 changes: 2 additions & 2 deletions include/utils/error/error_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class ErrorFactory {
void set_default_vendor_id(std::string vendor_id);

private:
const std::shared_ptr<ErrorTypeMap> error_type_map;

std::optional<ImplementationIdentifier> default_origin;
std::optional<Severity> default_severity;
std::optional<State> default_state;
Expand All @@ -52,8 +54,6 @@ class ErrorFactory {
std::optional<std::string> default_message;
std::optional<std::string> default_vendor_id;

const std::shared_ptr<ErrorTypeMap> error_type_map;

void set_description(Error& error) const;
};

Expand Down
8 changes: 4 additions & 4 deletions include/utils/error/error_manager_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class ErrorManagerImpl {
bool can_be_cleared(const ErrorType& type, const ErrorSubType& sub_type) const;
bool can_be_cleared(const ErrorType& type) const;

PublishErrorFunc publish_raised_error;
PublishErrorFunc publish_cleared_error;

std::shared_ptr<ErrorDatabase> database;
std::shared_ptr<ErrorTypeMap> error_type_map;
std::shared_ptr<ErrorDatabase> database;
std::list<ErrorType> allowed_error_types;

PublishErrorFunc publish_raised_error;
PublishErrorFunc publish_cleared_error;

const bool validate_error_types;
};

Expand Down
4 changes: 2 additions & 2 deletions include/utils/error/error_manager_req.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class ErrorManagerReq {
void on_error_cleared(const Error& error);
void on_error(const Error& error, const bool raised) const;

SubscribeErrorFunc subscribe_error_func;

std::shared_ptr<ErrorTypeMap> error_type_map;
std::shared_ptr<ErrorDatabase> database;
std::list<ErrorType> allowed_error_types;

SubscribeErrorFunc subscribe_error_func;
};

} // namespace error
Expand Down
8 changes: 4 additions & 4 deletions include/utils/error/error_manager_req_global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class ErrorManagerReqGlobal {
ErrorCallback clear_callback;
};

std::list<Subscription> subscriptions;

void on_error_raised(const Error& error);
void on_error_cleared(const Error& error);

SubscribeGlobalAllErrorsFunc subscribe_global_all_errors_func;

std::shared_ptr<ErrorTypeMap> error_type_map;
std::shared_ptr<ErrorDatabase> database;

SubscribeGlobalAllErrorsFunc subscribe_global_all_errors_func;

std::list<Subscription> subscriptions;
};

} // namespace error
Expand Down
6 changes: 2 additions & 4 deletions lib/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConfigParseException : public std::exception {
SCHEMA
};
ConfigParseException(ParseErrorType err_t, const std::string& entry, const std::string& what = "") :
err_t(err_t), entry(entry), what(what){};
err_t(err_t), entry(entry), what(what) {};

const ParseErrorType err_t;
const std::string entry;
Expand Down Expand Up @@ -397,7 +397,7 @@ std::tuple<json, int> Config::load_and_validate_with_schema(const fs::path& file
Config::Config(std::shared_ptr<RuntimeSettings> rs) : Config(rs, false) {
}

Config::Config(std::shared_ptr<RuntimeSettings> rs, bool manager) : rs(rs), manager(manager) {
Config::Config(std::shared_ptr<RuntimeSettings> rs, bool manager) : rs(rs) {
BOOST_LOG_FUNCTION();

this->manifests = json({});
Expand Down Expand Up @@ -530,8 +530,6 @@ Config::Config(std::shared_ptr<RuntimeSettings> rs, bool manager) : rs(rs), mana
}

if (probe_module_id) {
auto& manifest = this->manifests["ProbeModule"];

setup_probe_module_manifest(*probe_module_id, this->main, this->manifests);

load_and_validate_manifest(*probe_module_id, this->main.at(*probe_module_id));
Expand Down
4 changes: 2 additions & 2 deletions lib/error/error_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ std::list<ErrorPtr> ErrorManagerImpl::clear_error(const ErrorType& type, const b
std::list<ErrorPtr> res = database->remove_errors(filters);
std::stringstream ss;
ss << "Cleared " << res.size() << " errors of type " << type << " with sub_types:" << std::endl;
for (const ErrorPtr error : res) {
for (const ErrorPtr& error : res) {
this->publish_cleared_error(*error);
ss << " - " << error->sub_type << std::endl;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ std::list<ErrorPtr> ErrorManagerImpl::clear_all_errors() {
std::list<ErrorPtr> res = database->remove_errors(filters);
std::stringstream ss;
ss << "Cleared " << res.size() << " errors:" << std::endl;
for (const ErrorPtr error : res) {
for (const ErrorPtr& error : res) {
error->state = State::ClearedByModule;
this->publish_cleared_error(*error);
ss << " - type: " << error->type << ", sub_type: " << error->sub_type << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion lib/everest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ UnsubscribeToken Everest::provide_external_mqtt_handler(const std::string& topic

std::string external_topic = fmt::format("{}{}", this->mqtt_external_prefix, topic);

Handler external_handler = [this, handler, external_topic](json const& data) {
Handler external_handler = [handler, external_topic](json const& data) {
EVLOG_verbose << fmt::format("Incoming external mqtt data for topic '{}'...", external_topic);
if (!data.is_string()) {
EVLOG_AND_THROW(EverestInternalError("External mqtt result is not a string (that should never happen)"));
Expand Down

0 comments on commit f152d40

Please sign in to comment.