summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2018-09-05 12:02:39 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-09-05 19:59:34 +0000
commit2c8f93fb44cd08a6210f2b06d62ffb98677e7968 (patch)
treebfe5bd3b42a956ab50d236fe5a30a63531f7004f
parente0d6965e73f1f648ed02e483277f81a328ecb6df (diff)
downloadsdbusplus-2c8f93fb44cd08a6210f2b06d62ffb98677e7968.tar.gz
sdbusplus-2c8f93fb44cd08a6210f2b06d62ffb98677e7968.zip
sdbusplus::asio: fix callback with void args specialization
Callbacks with no arguments failed to build due to an error in the utility::get_first_arg template. It failed to provide a type member for the void specialization. With this fix, it is possible to have a handler that has no arguments. Tested by: Added a new callback to the asio-example.cpp. Without the template change, this caused the build to fail as expected. After adding the template change, the build succeeds and the example runs as expected. Change-Id: Ib09b58c76df8cba57dc093ab37a4c1b68ea11ad3 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
-rw-r--r--example/asio-example.cpp7
-rw-r--r--sdbusplus/utility/type_traits.hpp1
2 files changed, 8 insertions, 0 deletions
diff --git a/example/asio-example.cpp b/example/asio-example.cpp
index 31b55f2..354c7b0 100644
--- a/example/asio-example.cpp
+++ b/example/asio-example.cpp
@@ -17,6 +17,11 @@ int methodWithMessage(sdbusplus::message::message& m, int test)
return ++test;
}
+int voidBar(void)
+{
+ return 42;
+}
+
int main()
{
using GetSubTreeType = std::vector<std::pair<
@@ -121,6 +126,8 @@ int main()
iface->register_method("TestMethodWithMessage", methodWithMessage);
+ iface->register_method("VoidFunctionReturnsInt", voidBar);
+
iface->initialize();
iface->set_property("int", 45);
io.run();
diff --git a/sdbusplus/utility/type_traits.hpp b/sdbusplus/utility/type_traits.hpp
index fb6f0b6..2d60972 100644
--- a/sdbusplus/utility/type_traits.hpp
+++ b/sdbusplus/utility/type_traits.hpp
@@ -38,6 +38,7 @@ struct strip_first_arg<std::tuple<FirstArg, Rest...>>
template <typename T>
struct get_first_arg
{
+ using type = void;
};
template <typename FirstArg, typename... Rest>
OpenPOWER on IntegriCloud