1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-18 10:04:04 +03:00

manager: clean up audit/plymouth code a bit

Let's add assert()s, and let's put checks in similar order to emphasize
the symmetry. Also let's do cheap checks first.
This commit is contained in:
Lennart Poettering 2024-03-12 16:06:43 +01:00
parent e516c4d286
commit ad60cdd050

View File

@ -3361,18 +3361,20 @@ 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;
/* Don't generate audit events if the service was already started and we're just deserializing */
if (MANAGER_IS_RELOADING(m))
return;
audit_fd = get_audit_fd();
if (audit_fd < 0)
return;
/* Don't generate audit events if the service was already
* started and we're just deserializing */
if (MANAGER_IS_RELOADING(m))
return;
r = unit_name_to_prefix_and_instance(u->id, &p);
if (r < 0) {
log_warning_errno(r, "Failed to extract prefix and instance of unit name, ignoring: %m");
@ -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;