]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
login: simplify the condtion in assertion and slightly decrease binary size 11350/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Jan 2019 17:43:00 +0000 (02:43 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Jan 2019 14:44:50 +0000 (23:44 +0900)
src/login/logind-dbus.c

index bb3f6b845194fbd7c8078d6e0110a9b55ea143f7..8ab498fdc297af7e0c022b9fa332f71eb1f78540 100644 (file)
@@ -1474,23 +1474,15 @@ int manager_set_lid_switch_ignore(Manager *m, usec_t until) {
 }
 
 static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) {
-
-        static const char * const signal_name[_INHIBIT_WHAT_MAX] = {
-                [INHIBIT_SHUTDOWN] = "PrepareForShutdown",
-                [INHIBIT_SLEEP] = "PrepareForSleep"
-        };
-
         int active = _active;
 
         assert(m);
-        assert(w >= 0);
-        assert(w < _INHIBIT_WHAT_MAX);
-        assert(signal_name[w]);
+        assert(IN_SET(w, INHIBIT_SHUTDOWN, INHIBIT_SLEEP));
 
         return sd_bus_emit_signal(m->bus,
                                   "/org/freedesktop/login1",
                                   "org.freedesktop.login1.Manager",
-                                  signal_name[w],
+                                  w == INHIBIT_SHUTDOWN ? "PrepareForShutdown" : "PrepareForSleep",
                                   "b",
                                   active);
 }