]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: make manager_serialize() a bit easier to read by adding predicate function
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Oct 2018 18:35:28 +0000 (20:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Oct 2018 08:40:01 +0000 (10:40 +0200)
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.

src/core/manager.c

index c4fb60984a67f30dc7ab295dacc7d633c221d350..0737b6af3d68036362f9d1e2fd6f86f047dd4421 100644 (file)
@@ -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");