diff --git a/include/sdbus-c++/Message.h b/include/sdbus-c++/Message.h index 55455df..e70c9f5 100644 --- a/include/sdbus-c++/Message.h +++ b/include/sdbus-c++/Message.h @@ -71,7 +71,7 @@ namespace sdbus { * of @c IObject and @c IProxy. * ***********************************************/ - class Message + class [[nodiscard]] Message { public: Message& operator<<(bool item); @@ -275,7 +275,7 @@ namespace sdbus { template void serialize_pack(Message& msg, _Args&&... args) { - (msg << ... << args); + (void)(msg << ... << args); } template @@ -367,7 +367,7 @@ namespace sdbus { template void deserialize_pack(Message& msg, _Args&... args) { - (msg >> ... >> args); + (void)(msg >> ... >> args); } template diff --git a/include/sdbus-c++/TypeTraits.h b/include/sdbus-c++/TypeTraits.h index db1f85c..881e88a 100644 --- a/include/sdbus-c++/TypeTraits.h +++ b/include/sdbus-c++/TypeTraits.h @@ -488,7 +488,7 @@ namespace sdbus { static const std::string str() { std::string signature; - (signature += ... += signature_of>::str()); + (void)(signature += ... += signature_of>::str()); return signature; } }; diff --git a/tests/integrationtests/Connection_test.cpp b/tests/integrationtests/Connection_test.cpp index ea4915a..fd2ebfd 100644 --- a/tests/integrationtests/Connection_test.cpp +++ b/tests/integrationtests/Connection_test.cpp @@ -47,7 +47,7 @@ using ::testing::Eq; TEST(Connection, CanBeDefaultConstructed) { - ASSERT_NO_THROW(sdbus::createConnection()); + ASSERT_NO_THROW(auto con = sdbus::createConnection()); } TEST(Connection, CanRequestRegisteredDbusName) diff --git a/tests/integrationtests/TestingAdaptor.h b/tests/integrationtests/TestingAdaptor.h index 4ebdd65..65200c8 100644 --- a/tests/integrationtests/TestingAdaptor.h +++ b/tests/integrationtests/TestingAdaptor.h @@ -50,32 +50,32 @@ public: protected: - void noArgNoReturn() const + void noArgNoReturn() const override { } - int32_t getInt() const + int32_t getInt() const override { return INT32_VALUE; } - std::tuple getTuple() const + std::tuple getTuple() const override { return std::make_tuple(UINT32_VALUE, STRING_VALUE); } - double multiply(const int64_t& a, const double& b) const + double multiply(const int64_t& a, const double& b) const override { return a * b; } - void multiplyWithNoReply(const int64_t& a, const double& b) const + void multiplyWithNoReply(const int64_t& a, const double& b) const override { m_multiplyResult = a * b; m_wasMultiplyCalled = true; } - std::vector getInts16FromStruct(const sdbus::Struct>& x) const + std::vector getInts16FromStruct(const sdbus::Struct>& x) const override { std::vector res{x.get<1>()}; auto y = std::get>(x); @@ -83,13 +83,13 @@ protected: return res; } - sdbus::Variant processVariant(sdbus::Variant& v) + sdbus::Variant processVariant(sdbus::Variant& v) override { sdbus::Variant res = static_cast(v.get()); return res; } - std::map getMapOfVariants(const std::vector& x, const sdbus::Struct& y) const + std::map getMapOfVariants(const std::vector& x, const sdbus::Struct& y) const override { std::map res; for (auto item : x) @@ -99,12 +99,12 @@ protected: return res; } - sdbus::Struct>> getStructInStruct() const + sdbus::Struct>> getStructInStruct() const override { return sdbus::make_struct(STRING_VALUE, sdbus::make_struct(std::map{{INT32_VALUE, INT32_VALUE}})); } - int32_t sumStructItems(const sdbus::Struct& a, const sdbus::Struct& b) + int32_t sumStructItems(const sdbus::Struct& a, const sdbus::Struct& b) override { int32_t res{0}; res += std::get<0>(a) + std::get<1>(a); @@ -112,7 +112,7 @@ protected: return res; } - uint32_t sumVectorItems(const std::vector& a, const std::vector& b) + uint32_t sumVectorItems(const std::vector& a, const std::vector& b) override { uint32_t res{0}; for (auto x : a) @@ -126,13 +126,13 @@ protected: return res; } - uint32_t doOperation(uint32_t param) + uint32_t doOperation(uint32_t param) override { std::this_thread::sleep_for(std::chrono::milliseconds(param)); return param; } - void doOperationAsync(uint32_t param, sdbus::Result result) + void doOperationAsync(uint32_t param, sdbus::Result result) override { if (param == 0) { @@ -150,20 +150,20 @@ protected: } } - sdbus::Signature getSignature() const + sdbus::Signature getSignature() const override { return SIGNATURE_VALUE; } - sdbus::ObjectPath getObjectPath() const + sdbus::ObjectPath getObjectPath() const override { return OBJECT_PATH_VALUE; } - sdbus::UnixFd getUnixFd() const + sdbus::UnixFd getUnixFd() const override { return sdbus::UnixFd{UNIX_FD_VALUE}; } - ComplexType getComplex() const + ComplexType getComplex() const override { return { // map { @@ -191,7 +191,7 @@ protected: }; } - void throwError() const + void throwError() const override { m_wasThrowErrorCalled = true; throw sdbus::createError(1, "A test error occurred"); @@ -204,27 +204,27 @@ protected: emitSignalWithMap({}); } - std::string state() + std::string state() override { return m_state; } - uint32_t action() + uint32_t action() override { return m_action; } - void action(const uint32_t& value) + void action(const uint32_t& value) override { m_action = value; } - bool blocking() + bool blocking() override { return m_blocking; } - void blocking(const bool& value) + void blocking(const bool& value) override { m_blocking = value; } diff --git a/tests/unittests/Types_test.cpp b/tests/unittests/Types_test.cpp index f0d8f2b..41953a6 100644 --- a/tests/unittests/Types_test.cpp +++ b/tests/unittests/Types_test.cpp @@ -69,7 +69,7 @@ TEST(AVariant, CanBeConstructedFromAComplexValue) using ComplexType = std::map>>; ComplexType value{ {ANY_UINT64, ComplexType::mapped_type{sdbus::make_struct("hello"s, ANY_DOUBLE), sdbus::make_struct("world"s, ANY_DOUBLE)}} }; - ASSERT_NO_THROW(sdbus::Variant(value)); + ASSERT_NO_THROW(sdbus::Variant{value}); } TEST(AVariant, CanBeCopied)