]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/bootchart/bootchart.c
util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]
[thirdparty/systemd.git] / src / bootchart / bootchart.c
index 1625d51fa8098c9b982bb09a790d9cf5d1c5c7ce..c0019174ab8583c5214b411c5b9c1e0e89f970fd 100644 (file)
 
  ***/
 
-#include <sys/resource.h>
-#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <limits.h>
 #include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
+#include <sys/resource.h>
 #include <time.h>
-#include <getopt.h>
-#include <limits.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include "systemd/sd-journal.h"
+#include <unistd.h>
 
-#include "util.h"
+#include "sd-journal.h"
+
+#include "bootchart.h"
+#include "conf-parser.h"
+#include "fd-util.h"
 #include "fileio.h"
+#include "io-util.h"
+#include "list.h"
 #include "macro.h"
-#include "conf-parser.h"
-#include "strxcpyx.h"
+#include "parse-util.h"
 #include "path-util.h"
 #include "store.h"
+#include "string-util.h"
+#include "strxcpyx.h"
 #include "svg.h"
-#include "bootchart.h"
-#include "list.h"
+#include "util.h"
 
 static int exiting = 0;
 
@@ -338,10 +343,9 @@ int main(int argc, char *argv[]) {
          * - child logs data
          */
         if (getpid() == 1) {
-                if (fork()) {
+                if (fork())
                         /* parent */
                         execl(arg_init_path, arg_init_path, NULL);
-                }
         }
         argv[0][0] = '@';
 
@@ -367,7 +371,7 @@ int main(int argc, char *argv[]) {
                 struct timespec n;
                 double uptime;
 
-                clock_gettime(CLOCK_BOOTTIME, &n);
+                clock_gettime(clock_boottime_or_monotonic(), &n);
                 uptime = (n.tv_sec + (n.tv_nsec / (double) NSEC_PER_SEC));
 
                 log_start = gettime_ns();
@@ -438,10 +442,9 @@ int main(int argc, char *argv[]) {
 
                         res = nanosleep(&req, NULL);
                         if (res) {
-                                if (errno == EINTR) {
+                                if (errno == EINTR)
                                         /* caught signal, probably HUP! */
                                         break;
-                                }
                                 log_error_errno(errno, "nanosleep() failed: %m");
                                 return EXIT_FAILURE;
                         }
@@ -459,10 +462,7 @@ int main(int argc, char *argv[]) {
                 ps = ps->next_ps;
                 ps->schedstat = safe_close(ps->schedstat);
                 ps->sched = safe_close(ps->sched);
-                if (ps->smaps) {
-                        fclose(ps->smaps);
-                        ps->smaps = NULL;
-                }
+                ps->smaps = safe_fclose(ps->smaps);
         }
 
         if (!of) {