]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd/sd-event/test-event.c
tree-wide: use -EBADF also in pipe initializers
[thirdparty/systemd.git] / src / libsystemd / sd-event / test-event.c
index cc3b84cf46f542213abbea4bfca68d7908b94f8e..7cc4cc9e28382b125c52d8dc41d15a239c708506 100644 (file)
@@ -21,7 +21,6 @@
 #include "string-util.h"
 #include "tests.h"
 #include "tmpfile-util.h"
-#include "util.h"
 
 static int prepare_handler(sd_event_source *s, void *userdata) {
         log_info("preparing %c", PTR_TO_INT(userdata));
@@ -199,7 +198,8 @@ static void test_basic_one(bool with_pidfd) {
         sd_event *e = NULL;
         sd_event_source *w = NULL, *x = NULL, *y = NULL, *z = NULL, *q = NULL, *t = NULL;
         static const char ch = 'x';
-        int a[2] = { -1, -1 }, b[2] = { -1, -1}, d[2] = { -1, -1}, k[2] = { -1, -1 };
+        int a[2] = { -EBADF, -EBADF }, b[2] = { -EBADF, -EBADF },
+            d[2] = { -EBADF, -EBADF }, k[2] = { -EBADF, -EBADF };
         uint64_t event_now;
         int64_t priority;
 
@@ -226,8 +226,7 @@ static void test_basic_one(bool with_pidfd) {
 
         got_a = false, got_b = false, got_c = false, got_d = 0;
 
-        /* Add a oneshot handler, trigger it, reenable it, and trigger
-         * it again. */
+        /* Add a oneshot handler, trigger it, reenable it, and trigger it again. */
         assert_se(sd_event_add_io(e, &w, d[0], EPOLLIN, io_handler, INT_TO_PTR('d')) >= 0);
         assert_se(sd_event_source_set_enabled(w, SD_EVENT_ONESHOT) >= 0);
         assert_se(write(d[1], &ch, 1) >= 0);
@@ -655,7 +654,7 @@ TEST(ratelimit) {
 
         assert_se(sd_event_source_is_ratelimited(s) == 0);
         assert_se(count == 10);
-        log_info("ratelimit_io_handler: called %d times, event source not ratelimited", count);
+        log_info("ratelimit_io_handler: called %u times, event source not ratelimited", count);
 
         assert_se(sd_event_source_set_ratelimit(s, 0, 0) >= 0);
         assert_se(sd_event_source_set_ratelimit(s, 1 * USEC_PER_SEC, 5) >= 0);
@@ -666,7 +665,7 @@ TEST(ratelimit) {
                 assert_se(sd_event_run(e, UINT64_MAX) >= 0);
                 assert_se(usleep(10) >= 0);
         }
-        log_info("ratelimit_io_handler: called %d times, event source got ratelimited", count);
+        log_info("ratelimit_io_handler: called %u times, event source got ratelimited", count);
         assert_se(count < 10);
 
         s = sd_event_source_unref(s);
@@ -680,7 +679,7 @@ TEST(ratelimit) {
                 assert_se(sd_event_run(e, UINT64_MAX) >= 0);
         } while (!sd_event_source_is_ratelimited(s));
 
-        log_info("ratelimit_time_handler: called %d times, event source got ratelimited", count);
+        log_info("ratelimit_time_handler: called %u times, event source got ratelimited", count);
         assert_se(count == 10);
 
         /* In order to get rid of active rate limit client needs to disable it explicitly */
@@ -743,7 +742,7 @@ TEST(inotify_self_destroy) {
         _cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL;
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
         char path[] = "/tmp/inotifyXXXXXX";
-        _cleanup_close_ int fd = -1;
+        _cleanup_close_ int fd = -EBADF;
 
         /* Tests that destroying an inotify event source from its own handler is safe */