X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Ftest-inhibit.c;h=274687d20f38abf22edf6b153d8c6d98db096c4e;hb=5e07a79e84ab8b045b9df1a2719f14fc84471a1d;hp=70b8314e3f8481d47600804891e89e38c5d56ef7;hpb=997d4ae7f2d59c2f624f0856e70d448c4f98bc96;p=elogind.git diff --git a/src/login/test-inhibit.c b/src/login/test-inhibit.c index 70b8314e3..274687d20 100644 --- a/src/login/test-inhibit.c +++ b/src/login/test-inhibit.c @@ -42,11 +42,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 +67,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 +89,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);