From 44c3db01709da5a5fa5fff663ee46a4e820bda5d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 2 Feb 2021 23:04:25 +0100 Subject: Be explicit in types used in dbus Cast to uint32_t for total and int64_t for epoch to be libc++ and environment agnostic. --- src/timer_state.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/timer_state.cc') diff --git a/src/timer_state.cc b/src/timer_state.cc index b7b4309..7700f80 100644 --- a/src/timer_state.cc +++ b/src/timer_state.cc @@ -81,7 +81,7 @@ public: try { proxy_ = sdbus::createProxy(*conn_.get(), kServiceName, kObjectPath); proxy_->uponSignal("started").onInterface(kInterfaceName) - .call([this](uint32_t total, time_t epoch){ + .call([this](uint32_t total, int64_t epoch){ signal_started(std::chrono::minutes(total), std::chrono::system_clock::from_time_t(epoch)); }); @@ -139,7 +139,7 @@ private: auto reply = proxy_->callMethod(std::move(method)); bool active; uint32_t total; - time_t epoch; + int64_t epoch; reply >> active; reply >> total; reply >> epoch; @@ -169,7 +169,8 @@ public: try { object_->emitSignal("started").onInterface(kInterfaceName).withArguments( - total_.count(), std::chrono::system_clock::to_time_t(start_)); + static_cast(total_.count()), + static_cast(std::chrono::system_clock::to_time_t(start_))); } catch (sdbus::Error const& err) { std::cerr << "Failed to emit started: " << err.what() << std::endl; } @@ -186,7 +187,7 @@ public: try { object_->emitSignal("stopped").onInterface(kInterfaceName).withArguments( - total_.count()); + static_cast(total_.count())); } catch (sdbus::Error const& err) { std::cerr << "Failed to emit started: " << err.what() << std::endl; } @@ -225,7 +226,7 @@ public: std::bind(&TimerStateServer::get_state, this, std::placeholders::_1); object->registerMethod(kInterfaceName, "get_state", "", "bux", call_fun); object->registerSignal("started").onInterface(kInterfaceName) - .withParameters(); + .withParameters(); object->registerSignal("stopped").onInterface(kInterfaceName) .withParameters(); object->registerSignal("reset").onInterface(kInterfaceName); @@ -253,9 +254,10 @@ private: reply << active_; reply << static_cast(total_.count()); if (active_) { - reply << std::chrono::system_clock::to_time_t(start_); + reply << static_cast( + std::chrono::system_clock::to_time_t(start_)); } else { - reply << static_cast(0); + reply << static_cast(0); } reply.send(); } catch (sdbus::Error const& err) { -- cgit v1.2.3-70-g09d2