|
|
594167 |
From 6ddb7fc35d7051627fa2772226e07296c28b316f Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
594167 |
Date: Sun, 17 Apr 2022 07:35:05 +0900
|
|
|
594167 |
Subject: [PATCH] test: shorten code a bit
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit 63ec7a849039fab830961fd7fee0c1e266735fc8)
|
|
|
594167 |
|
|
|
594167 |
Related: #2087652
|
|
|
594167 |
---
|
|
|
594167 |
src/libsystemd/sd-bus/test-bus-track.c | 39 +++++++++-----------------
|
|
|
594167 |
1 file changed, 13 insertions(+), 26 deletions(-)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/src/libsystemd/sd-bus/test-bus-track.c b/src/libsystemd/sd-bus/test-bus-track.c
|
|
|
594167 |
index 64aa88bb4f..238934a880 100644
|
|
|
594167 |
--- a/src/libsystemd/sd-bus/test-bus-track.c
|
|
|
594167 |
+++ b/src/libsystemd/sd-bus/test-bus-track.c
|
|
|
594167 |
@@ -26,7 +26,6 @@ static int track_cb_x(sd_bus_track *t, void *userdata) {
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
static int track_cb_y(sd_bus_track *t, void *userdata) {
|
|
|
594167 |
- int r;
|
|
|
594167 |
|
|
|
594167 |
log_error("TRACK CB Y");
|
|
|
594167 |
|
|
|
594167 |
@@ -35,8 +34,7 @@ static int track_cb_y(sd_bus_track *t, void *userdata) {
|
|
|
594167 |
|
|
|
594167 |
/* We got disconnected, let's close everything */
|
|
|
594167 |
|
|
|
594167 |
- r = sd_event_exit(sd_bus_get_event(sd_bus_track_get_bus(t)), EXIT_SUCCESS);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_event_exit(sd_bus_get_event(sd_bus_track_get_bus(t)), EXIT_SUCCESS) >= 0);
|
|
|
594167 |
|
|
|
594167 |
return 0;
|
|
|
594167 |
}
|
|
|
594167 |
@@ -51,8 +49,7 @@ int main(int argc, char *argv[]) {
|
|
|
594167 |
|
|
|
594167 |
test_setup_logging(LOG_INFO);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_event_default(&event);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_event_default(&event) >= 0);
|
|
|
594167 |
|
|
|
594167 |
r = sd_bus_open_user(&a);
|
|
|
594167 |
if (IN_SET(r, -ECONNREFUSED, -ENOENT, -ENOMEDIUM)) {
|
|
|
594167 |
@@ -63,43 +60,33 @@ int main(int argc, char *argv[]) {
|
|
|
594167 |
}
|
|
|
594167 |
assert_se(r >= 0);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL) >= 0);
|
|
|
594167 |
|
|
|
594167 |
if (use_system_bus)
|
|
|
594167 |
- r = sd_bus_open_system(&b);
|
|
|
594167 |
+ assert_se(sd_bus_open_system(&b) >= 0);
|
|
|
594167 |
else
|
|
|
594167 |
- r = sd_bus_open_user(&b);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_open_user(&b) >= 0);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_bus_attach_event(b, event, SD_EVENT_PRIORITY_NORMAL);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_attach_event(b, event, SD_EVENT_PRIORITY_NORMAL) >= 0);
|
|
|
594167 |
|
|
|
594167 |
/* Watch b's name from a */
|
|
|
594167 |
- r = sd_bus_track_new(a, &x, track_cb_x, NULL);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_track_new(a, &x, track_cb_x, NULL) >= 0);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_bus_get_unique_name(b, &unique);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_get_unique_name(b, &unique) >= 0);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_bus_track_add_name(x, unique);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_track_add_name(x, unique) >= 0);
|
|
|
594167 |
|
|
|
594167 |
/* Watch's a's own name from a */
|
|
|
594167 |
- r = sd_bus_track_new(a, &y, track_cb_y, NULL);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_track_new(a, &y, track_cb_y, NULL) >= 0);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_bus_get_unique_name(a, &unique);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_get_unique_name(a, &unique) >= 0);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_bus_track_add_name(y, unique);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_bus_track_add_name(y, unique) >= 0);
|
|
|
594167 |
|
|
|
594167 |
/* Now make b's name disappear */
|
|
|
594167 |
sd_bus_close(b);
|
|
|
594167 |
|
|
|
594167 |
- r = sd_event_loop(event);
|
|
|
594167 |
- assert_se(r >= 0);
|
|
|
594167 |
+ assert_se(sd_event_loop(event) >= 0);
|
|
|
594167 |
|
|
|
594167 |
assert_se(track_cb_called_x);
|
|
|
594167 |
assert_se(track_cb_called_y);
|