ryantimwilson / rpms / systemd

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