summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-05-14 22:41:19 +0200
committerLennart Poettering <lennart@poettering.net>2015-05-14 22:41:19 +0200
commit0e85114376b7d28c79d0a66996d1bc1a1ee01724 (patch)
tree1befa8b93b0433a22b7a1abbdc2c48c63c92b121 /src/libsystemd
parent2f50a2d55bf0a8b5959a6864ae1b39e7e9e0ce08 (diff)
test-bus-chat: various modernizations
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 1e50dfc433..046e999008 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -263,10 +263,10 @@ fail:
static void* client1(void*p) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_close_unref_ sd_bus *bus = NULL;
- sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
const char *hello;
int r;
- int pp[2] = { -1, -1 };
+ _cleanup_close_pair_ int pp[2] = { -1, -1 };
char x;
r = sd_bus_open_user(&bus);
@@ -347,10 +347,6 @@ finish:
}
- sd_bus_error_free(&error);
-
- safe_close_pair(pp);
-
return INT_TO_PTR(r);
}
@@ -365,8 +361,8 @@ static int quit_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_er
static void* client2(void*p) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
- sd_bus *bus = NULL;
- sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
bool quit = false;
const char *mid;
int r;
@@ -395,8 +391,7 @@ static void* client2(void*p) {
goto finish;
}
- sd_bus_message_unref(m);
- m = NULL;
+ m = sd_bus_message_unref(m);
r = sd_bus_message_new_signal(
bus,
@@ -415,8 +410,7 @@ static void* client2(void*p) {
goto finish;
}
- sd_bus_message_unref(m);
- m = NULL;
+ m = sd_bus_message_unref(m);
r = sd_bus_message_new_method_call(
bus,
@@ -444,8 +438,7 @@ static void* client2(void*p) {
log_info("Machine ID is %s.", mid);
- sd_bus_message_unref(m);
- m = NULL;
+ m = sd_bus_message_unref(m);
r = sd_bus_message_new_method_call(
bus,
@@ -459,8 +452,7 @@ static void* client2(void*p) {
goto finish;
}
- sd_bus_message_unref(reply);
- reply = NULL;
+ reply = sd_bus_message_unref(reply);
r = sd_bus_call(bus, m, 200 * USEC_PER_MSEC, &error, &reply);
if (r < 0)
@@ -468,8 +460,7 @@ static void* client2(void*p) {
else
log_info("Slow call succeed.");
- sd_bus_message_unref(m);
- m = NULL;
+ m = sd_bus_message_unref(m);
r = sd_bus_message_new_method_call(
bus,
@@ -522,12 +513,9 @@ finish:
goto finish;
}
- sd_bus_send(bus, q, NULL);
- sd_bus_flush(bus);
- sd_bus_unref(bus);
+ (void) sd_bus_send(bus, q, NULL);
}
- sd_bus_error_free(&error);
return INT_TO_PTR(r);
}