diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-04-17 00:35:05 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-04-19 11:02:10 +0200 |
commit | 63ec7a849039fab830961fd7fee0c1e266735fc8 (patch) | |
tree | 2cc15e2b20c750283cb034f408028a007f1d7b71 /src | |
parent | sd-bus: use hashmap_contains() and drop unnecessary cast (diff) | |
download | systemd-63ec7a849039fab830961fd7fee0c1e266735fc8.tar.xz systemd-63ec7a849039fab830961fd7fee0c1e266735fc8.zip |
test: shorten code a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-track.c | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-track.c b/src/libsystemd/sd-bus/test-bus-track.c index 64aa88bb4f..238934a880 100644 --- a/src/libsystemd/sd-bus/test-bus-track.c +++ b/src/libsystemd/sd-bus/test-bus-track.c @@ -26,7 +26,6 @@ static int track_cb_x(sd_bus_track *t, void *userdata) { } static int track_cb_y(sd_bus_track *t, void *userdata) { - int r; log_error("TRACK CB Y"); @@ -35,8 +34,7 @@ static int track_cb_y(sd_bus_track *t, void *userdata) { /* We got disconnected, let's close everything */ - r = sd_event_exit(sd_bus_get_event(sd_bus_track_get_bus(t)), EXIT_SUCCESS); - assert_se(r >= 0); + assert_se(sd_event_exit(sd_bus_get_event(sd_bus_track_get_bus(t)), EXIT_SUCCESS) >= 0); return 0; } @@ -51,8 +49,7 @@ int main(int argc, char *argv[]) { test_setup_logging(LOG_INFO); - r = sd_event_default(&event); - assert_se(r >= 0); + assert_se(sd_event_default(&event) >= 0); r = sd_bus_open_user(&a); if (IN_SET(r, -ECONNREFUSED, -ENOENT, -ENOMEDIUM)) { @@ -63,43 +60,33 @@ int main(int argc, char *argv[]) { } assert_se(r >= 0); - r = sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL); - assert_se(r >= 0); + assert_se(sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL) >= 0); if (use_system_bus) - r = sd_bus_open_system(&b); + assert_se(sd_bus_open_system(&b) >= 0); else - r = sd_bus_open_user(&b); - assert_se(r >= 0); + assert_se(sd_bus_open_user(&b) >= 0); - r = sd_bus_attach_event(b, event, SD_EVENT_PRIORITY_NORMAL); - assert_se(r >= 0); + assert_se(sd_bus_attach_event(b, event, SD_EVENT_PRIORITY_NORMAL) >= 0); /* Watch b's name from a */ - r = sd_bus_track_new(a, &x, track_cb_x, NULL); - assert_se(r >= 0); + assert_se(sd_bus_track_new(a, &x, track_cb_x, NULL) >= 0); - r = sd_bus_get_unique_name(b, &unique); - assert_se(r >= 0); + assert_se(sd_bus_get_unique_name(b, &unique) >= 0); - r = sd_bus_track_add_name(x, unique); - assert_se(r >= 0); + assert_se(sd_bus_track_add_name(x, unique) >= 0); /* Watch's a's own name from a */ - r = sd_bus_track_new(a, &y, track_cb_y, NULL); - assert_se(r >= 0); + assert_se(sd_bus_track_new(a, &y, track_cb_y, NULL) >= 0); - r = sd_bus_get_unique_name(a, &unique); - assert_se(r >= 0); + assert_se(sd_bus_get_unique_name(a, &unique) >= 0); - r = sd_bus_track_add_name(y, unique); - assert_se(r >= 0); + assert_se(sd_bus_track_add_name(y, unique) >= 0); /* Now make b's name disappear */ sd_bus_close(b); - r = sd_event_loop(event); - assert_se(r >= 0); + assert_se(sd_event_loop(event) >= 0); assert_se(track_cb_called_x); assert_se(track_cb_called_y); |