From 6bfb45bea49826c9f914ceb3676b60d60e73aaa4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 11 May 2018 18:10:25 +0900 Subject: [PATCH] dbus-swap: use BUS_DEFINE_PROPERTY_GET* macros --- src/core/dbus-swap.c | 56 ++++++++++---------------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c index 387a68f9037..f4422057775 100644 --- a/src/core/dbus-swap.c +++ b/src/core/dbus-swap.c @@ -14,54 +14,22 @@ #include "swap.h" #include "unit.h" -static int property_get_priority( - sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *error) { - - Swap *s = SWAP(userdata); - int p; - - assert(bus); - assert(reply); - assert(s); - +static int swap_get_priority(Swap *s) { if (s->from_proc_swaps) - p = s->parameters_proc_swaps.priority; - else if (s->from_fragment) - p = s->parameters_fragment.priority; - else - p = -1; - - return sd_bus_message_append(reply, "i", p); -} - -static int property_get_options( - sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *error) { - - Swap *s = SWAP(userdata); - const char *options = NULL; - - assert(bus); - assert(reply); - assert(s); - + return s->parameters_proc_swaps.priority; if (s->from_fragment) - options = s->parameters_fragment.options; - - return sd_bus_message_append(reply, "s", options); + return s->parameters_fragment.priority; + return -1; } +static const char *swap_get_options(Swap *s) { + if (s->from_fragment) + return s->parameters_fragment.options; + return NULL; +} + +static BUS_DEFINE_PROPERTY_GET(property_get_priority, "i", Swap, swap_get_priority); +static BUS_DEFINE_PROPERTY_GET(property_get_options, "s", Swap, swap_get_options); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, swap_result, SwapResult); const sd_bus_vtable bus_swap_vtable[] = {