]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
manager: clean up audit/plymouth code a bit
authorLennart Poettering <lennart@poettering.net>
Tue, 12 Mar 2024 15:06:43 +0000 (16:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 Mar 2024 16:23:06 +0000 (17:23 +0100)
Let's add assert()s, and let's put checks in similar order to emphasize
the symmetry. Also let's do cheap checks first.

src/core/manager.c

index 1992cd603ebf4f8c75e7c0cb8eb0dcc8c28e6704..2ef8ad90daabdb5141f227fd2be7fa040292f47d 100644 (file)
@@ -3361,16 +3361,18 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
         const char *msg;
         int audit_fd, r;
 
+        assert(m);
+        assert(u);
+
         if (!MANAGER_IS_SYSTEM(m))
                 return;
 
-        audit_fd = get_audit_fd();
-        if (audit_fd < 0)
+        /* Don't generate audit events if the service was already started and we're just deserializing */
+        if (MANAGER_IS_RELOADING(m))
                 return;
 
-        /* Don't generate audit events if the service was already
-         * started and we're just deserializing */
-        if (MANAGER_IS_RELOADING(m))
+        audit_fd = get_audit_fd();
+        if (audit_fd < 0)
                 return;
 
         r = unit_name_to_prefix_and_instance(u->id, &p);
@@ -3389,21 +3391,22 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
                         log_warning_errno(errno, "Failed to send audit message, ignoring: %m");
         }
 #endif
-
 }
 
 void manager_send_unit_plymouth(Manager *m, Unit *u) {
         _cleanup_free_ char *message = NULL;
         int c, r;
 
-        /* Don't generate plymouth events if the service was already
-         * started and we're just deserializing */
-        if (MANAGER_IS_RELOADING(m))
-                return;
+        assert(m);
+        assert(u);
 
         if (!MANAGER_IS_SYSTEM(m))
                 return;
 
+        /* Don't generate plymouth events if the service was already started and we're just deserializing */
+        if (MANAGER_IS_RELOADING(m))
+                return;
+
         if (detect_container() > 0)
                 return;