Fix compilation error in case unix_fd is used in async_method_call
unix_fd has fd sanitization in its append routine. It makes it impossible
to use unix_fd in async_method_call, as it explicitly applies const qualifier
to all message arguments.
To keep previous behavior in current unix_fd clients I've added specialization
inside append routine for variables passed by const reference.
Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
Change-Id: I3409f9f2b40d14d9486eca203321333ad1bb2efa
diff --git a/sdbusplus/message/append.hpp b/sdbusplus/message/append.hpp
index 058e277..a7715ae 100644
--- a/sdbusplus/message/append.hpp
+++ b/sdbusplus/message/append.hpp
@@ -178,13 +178,24 @@
struct append_single<details::unix_fd_type>
{
template <typename T>
+ static void sanitize(const T& s)
+ {
+ }
+
+ template <typename T>
+ static void sanitize(T& s)
+ {
+ s.fd = -1;
+ }
+
+ template <typename T>
static void op(sdbusplus::SdBusInterface* intf, sd_bus_message* m, T&& s)
{
constexpr auto dbusType = std::get<0>(types::type_id<T>());
intf->sd_bus_message_append_basic(m, dbusType, &s.fd);
// sd-bus now owns the file descriptor
- s.fd = -1;
+ sanitize(s);
}
};