1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

dbus-swap: use BUS_DEFINE_PROPERTY_GET* macros

This commit is contained in:
Yu Watanabe 2018-05-11 18:10:25 +09:00
parent a54f28bc1e
commit 6bfb45bea4

View File

@ -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[] = {