chiark / gitweb /
Prep v225: Added needed udev support and re-enabled some masked cgroup functions.
[elogind.git] / src / login / test-inhibit.c
index 70b8314e3f8481d47600804891e89e38c5d56ef7..03516de916b02bd57afc9673bef0d7e463aa9bdc 100644 (file)
@@ -25,7 +25,6 @@
 #include "util.h"
 #include "sd-bus.h"
 #include "bus-util.h"
-#include "bus-error.h"
 
 static int inhibit(sd_bus *bus, const char *what) {
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
@@ -42,11 +41,11 @@ static int inhibit(sd_bus *bus, const char *what) {
                         &error,
                         &reply,
                         "ssss", what, who, reason, mode);
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         r = sd_bus_message_read_basic(reply, SD_BUS_TYPE_UNIX_FD, &fd);
-        assert(r >= 0);
-        assert(fd >= 0);
+        assert_se(r >= 0);
+        assert_se(fd >= 0);
 
         return dup(fd);
 }
@@ -67,18 +66,18 @@ static void print_inhibitors(sd_bus *bus) {
                         &error,
                         &reply,
                         "");
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssuu)");
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         while ((r = sd_bus_message_read(reply, "(ssssuu)", &what, &who, &why, &mode, &uid, &pid)) > 0) {
-                printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<%lu> pid=<%lu>\n",
-                       what, who, why, mode, (unsigned long) uid, (unsigned long) pid);
+                printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<%"PRIu32"> pid=<%"PRIu32">\n",
+                       what, who, why, mode, uid, pid);
 
                 n++;
         }
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         printf("%u inhibitors\n", n);
 }
@@ -89,23 +88,23 @@ int main(int argc, char*argv[]) {
         int r;
 
         r = sd_bus_open_system(&bus);
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         print_inhibitors(bus);
 
         fd1 = inhibit(bus, "sleep");
-        assert(fd1 >= 0);
+        assert_se(fd1 >= 0);
         print_inhibitors(bus);
 
         fd2 = inhibit(bus, "idle:shutdown");
-        assert(fd2 >= 0);
+        assert_se(fd2 >= 0);
         print_inhibitors(bus);
 
-        close_nointr_nofail(fd1);
+        safe_close(fd1);
         sleep(1);
         print_inhibitors(bus);
 
-        close_nointr_nofail(fd2);
+        safe_close(fd2);
         sleep(1);
         print_inhibitors(bus);