Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "debug")
ADD_DEFINITIONS(-g3 -O0 -Weverything)

ADD_DEFINITIONS(-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded)
ADD_DEFINITIONS(-Wno-c++98-compat -Wno-shadow -Wno-c++98-compat-pedantic -Wno-padded)
ADD_DEFINITIONS(-Wno-exit-time-destructors -Wno-global-constructors)
endif()

# Options required to reduce the noise of spdlog
ADD_DEFINITIONS(-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-sign-conversion -Wno-padded -Wno-switch-enum)
ADD_DEFINITIONS(-Wno-old-style-cast -Wno-undef -Wno-documentation-unknown-command)
ADD_DEFINITIONS(-Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors -Wno-newline-eof)
ADD_DEFINITIONS(-Wno-missing-variable-declarations -Wno-double-promotion -Wno-extra-semi)

elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Using GCC
if ("${CMAKE_BUILD_TYPE}" STREQUAL "release")
Expand Down
2 changes: 2 additions & 0 deletions include/fast-lib/message/migfra/time_measurement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Time_measurement :
{
public:
explicit Time_measurement(bool enable_time_measurement = false, std::string format = "", Timer::timepoint_type base_point = Timer::clock::now());
Time_measurement(const Time_measurement &rhs) = default;
Time_measurement & operator=(const Time_measurement &rhs) = default;
~Time_measurement();

void tick(const std::string &timer_name);
Expand Down
1 change: 1 addition & 0 deletions include/fast-lib/serializable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace fast
public:
Serializable() = default;
Serializable(const Serializable&) = default;
Serializable & operator=(const Serializable &rhs) = default;
virtual ~Serializable() = default;

virtual YAML::Node emit() const = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/message/migfra/pci_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ YAML::Node PCI_id::emit() const

void PCI_id::load(const YAML::Node &node)
{
vendor = std::stoul(node["vendor"].as<std::string>(), nullptr, 0);
device = std::stoul(node["device"].as<std::string>(), nullptr, 0);
vendor = static_cast<vendor_t>(std::stoul(node["vendor"].as<std::string>(), nullptr, 0));
device = static_cast<device_t>(std::stoul(node["device"].as<std::string>(), nullptr, 0));
}

std::ostream & operator<<(std::ostream &os, const PCI_id &rhs)
Expand Down
16 changes: 8 additions & 8 deletions src/message/migfra/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,49 +122,49 @@ YAML::Node Task_container::emit() const
Task_container::no_task_exception::no_task_exception(const std::string &str)
: std::runtime_error(str) {}

std::vector<std::shared_ptr<Task>> load_start_task(const YAML::Node &node)
static std::vector<std::shared_ptr<Task>> load_start_task(const YAML::Node &node)
{
std::vector<std::shared_ptr<Start>> tasks;
fast::load(tasks, node["vm-configurations"]);
return std::vector<std::shared_ptr<Task>>(tasks.begin(), tasks.end());
}

std::vector<std::shared_ptr<Task>> load_stop_task(const YAML::Node &node)
static std::vector<std::shared_ptr<Task>> load_stop_task(const YAML::Node &node)
{
std::vector<std::shared_ptr<Stop>> tasks;
fast::load(tasks, node["list"]);
return std::vector<std::shared_ptr<Task>>(tasks.begin(), tasks.end());
}

std::vector<std::shared_ptr<Task>> load_migrate_task(const YAML::Node &node)
static std::vector<std::shared_ptr<Task>> load_migrate_task(const YAML::Node &node)
{
std::shared_ptr<Migrate> migrate_task;
fast::load(migrate_task, node);
return std::vector<std::shared_ptr<Task>>(1, migrate_task);
}

std::vector<std::shared_ptr<Task>> load_repin_task(const YAML::Node &node)
static std::vector<std::shared_ptr<Task>> load_repin_task(const YAML::Node &node)
{
std::shared_ptr<Repin> repin_task;
fast::load(repin_task, node);
return std::vector<std::shared_ptr<Task>>(1, repin_task);
}

std::vector<std::shared_ptr<Task>> load_suspend_task(const YAML::Node &node)
static std::vector<std::shared_ptr<Task>> load_suspend_task(const YAML::Node &node)
{
std::vector<std::shared_ptr<Suspend>> tasks;
fast::load(tasks, node["list"]);
return std::vector<std::shared_ptr<Task>>(tasks.begin(), tasks.end());
}

std::vector<std::shared_ptr<Task>> load_resume_task(const YAML::Node &node)
static std::vector<std::shared_ptr<Task>> load_resume_task(const YAML::Node &node)
{
std::vector<std::shared_ptr<Resume>> tasks;
fast::load(tasks, node["list"]);
return std::vector<std::shared_ptr<Task>>(tasks.begin(), tasks.end());
}

std::vector<std::shared_ptr<Task>> load_quit_task(const YAML::Node &node)
static std::vector<std::shared_ptr<Task>> load_quit_task(const YAML::Node &node)
{
std::shared_ptr<Quit> quit_task;
fast::load(quit_task, node);
Expand All @@ -176,7 +176,7 @@ void Task_container::load(const YAML::Node &node)
std::string type;
try {
fast::load(type, node["task"]);
} catch (const std::exception &e) {
} catch (const std::exception /*&e*/) {
throw Task_container::no_task_exception("Cannot find key \"task\" to load Task from YAML.");
}
if (type == "start vm") {
Expand Down
2 changes: 1 addition & 1 deletion src/message/migfra/time_measurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void Time_measurement::tock(const std::string &timer_name)
if (enabled) {
try {
timers.at(timer_name).stop();
} catch (const std::out_of_range &e) {
} catch (const std::out_of_range /*&e*/) {
throw std::runtime_error("Timer with name \"" + timer_name + "\" not found. Search for a tock without preceding tick.");
}
}
Expand Down
28 changes: 15 additions & 13 deletions src/mqtt_communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,23 @@ FASTLIB_LOG_SET_LEVEL_GLOBAL(comm_log, trace);
namespace fast {

/// Helper function to make error codes human readable.
std::string mosq_err_string(const std::string &str, int code)
static std::string mosq_err_string(const std::string &str, int code)
{
return str + mosqpp::strerror(code);
}

/// Helper function to convert a given topic into a regular expression
static std::regex topic_to_regex(const std::string &topic)
{
// Replace "+" by "[^/]*"
auto regex_topic = std::regex_replace(topic, std::regex(R"((\+))"), R"([^/]*)");
// Replace "#" by "[^/]*(?:/[^/]*)*$"
regex_topic = std::regex_replace(regex_topic, std::regex(R"((#))"), R"([^/]*(?:/[^/]*)*$)");
return std::regex(regex_topic);
}



class MQTT_subscription
{
public:
Expand Down Expand Up @@ -249,15 +261,6 @@ void MQTT_communicator::on_disconnect(int rc)
}


std::regex topic_to_regex(const std::string &topic)
{
// Replace "+" by "[^/]*"
auto regex_topic = std::regex_replace(topic, std::regex(R"((\+))"), R"([^/]*)");
// Replace "#" by "[^/]*(?:/[^/]*)*$"
regex_topic = std::regex_replace(regex_topic, std::regex(R"((#))"), R"([^/]*(?:/[^/]*)*$)");
return std::regex(regex_topic);
}

void MQTT_communicator::on_message(const mosquitto_message *msg)
{
FASTLIB_LOG(comm_log, trace) << "Callback: on_message with topic: " << msg->topic;
Expand Down Expand Up @@ -294,7 +297,7 @@ void MQTT_communicator::send_message(const std::string &message, const std::stri
// Use default topic if empty string is passed.
auto &real_topic = topic == "" ? default_publish_topic : topic;
// Publish message to topic.
int ret = publish(nullptr, real_topic.c_str(), message.size(), message.c_str(), qos, false);
int ret = publish(nullptr, real_topic.c_str(), static_cast<int>(message.size()), message.c_str(), qos, false);
if (ret != MOSQ_ERR_SUCCESS)
throw std::runtime_error(mosq_err_string("Error sending message: ", ret));
FASTLIB_LOG(comm_log, trace) << "Message sent to topic " << real_topic << ".";
Expand Down Expand Up @@ -325,10 +328,9 @@ std::string MQTT_communicator::get_message(const std::string &topic, const std::
auto &subscription = subscriptions.at(topic);
lock.unlock();
return subscription->get_message(duration, actual_topic);
} catch (const std::out_of_range &e) {
} catch (const std::out_of_range /*&e*/) {
throw std::out_of_range("Topic not found in subscriptions.");
}
FASTLIB_LOG(comm_log, trace) << "Message got.";
}


Expand Down