From: Lennart Poettering Date: Wed, 17 Oct 2018 18:35:28 +0000 (+0200) Subject: core: make manager_serialize() a bit easier to read by adding predicate function X-Git-Tag: v240~466^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cdd620e3460b08d1f5b80cefefef352de42fb792;p=thirdparty%2Fsystemd.git core: make manager_serialize() a bit easier to read by adding predicate function The predicate function manager_timestamp_shall_serialize() simply says whether to serialize or not serialize a timestamp, and should make things a bit easier to read. --- diff --git a/src/core/manager.c b/src/core/manager.c index c4fb60984a6..0737b6af3d6 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3082,6 +3082,19 @@ int manager_open_serialization(Manager *m, FILE **_f) { return 0; } +static bool manager_timestamp_shall_serialize(ManagerTimestamp t) { + + if (!in_initrd()) + return true; + + /* The following timestamps only apply to the host system, hence only serialize them there */ + return !IN_SET(t, + MANAGER_TIMESTAMP_USERSPACE, MANAGER_TIMESTAMP_FINISH, + MANAGER_TIMESTAMP_SECURITY_START, MANAGER_TIMESTAMP_SECURITY_FINISH, + MANAGER_TIMESTAMP_GENERATORS_START, MANAGER_TIMESTAMP_GENERATORS_FINISH, + MANAGER_TIMESTAMP_UNITS_LOAD_START, MANAGER_TIMESTAMP_UNITS_LOAD_FINISH); +} + int manager_serialize( Manager *m, FILE *f, @@ -3120,12 +3133,7 @@ int manager_serialize( for (q = 0; q < _MANAGER_TIMESTAMP_MAX; q++) { _cleanup_free_ char *joined = NULL; - /* The following timestamps only apply to the host system, hence only serialize them there */ - if (in_initrd() && - IN_SET(q, MANAGER_TIMESTAMP_USERSPACE, MANAGER_TIMESTAMP_FINISH, - MANAGER_TIMESTAMP_SECURITY_START, MANAGER_TIMESTAMP_SECURITY_FINISH, - MANAGER_TIMESTAMP_GENERATORS_START, MANAGER_TIMESTAMP_GENERATORS_FINISH, - MANAGER_TIMESTAMP_UNITS_LOAD_START, MANAGER_TIMESTAMP_UNITS_LOAD_FINISH)) + if (!manager_timestamp_shall_serialize(q)) continue; joined = strjoin(manager_timestamp_to_string(q), "-timestamp");