X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbootchart%2Fstore.c;h=ed683e88d97472fb11c42ea5c55c2dd1cf1ca656;hb=d498a616075ebfd8025d66c4c4f725d24eb3aca3;hp=cedcba88ed1b8059c03281c75cd2a8fc1c52f992;hpb=c358d728e7d6bf38a0176a9d5d013c6e972cddbf;p=elogind.git diff --git a/src/bootchart/store.c b/src/bootchart/store.c index cedcba88e..ed683e88d 100644 --- a/src/bootchart/store.c +++ b/src/bootchart/store.c @@ -34,6 +34,7 @@ #include #include "util.h" +#include "time-util.h" #include "strxcpyx.h" #include "store.h" #include "bootchart.h" @@ -54,14 +55,14 @@ double gettime_ns(void) { clock_gettime(CLOCK_MONOTONIC, &n); - return (n.tv_sec + (n.tv_nsec / 1000000000.0)); + return (n.tv_sec + (n.tv_nsec / (double) NSEC_PER_SEC)); } static double gettime_up(void) { struct timespec n; clock_gettime(CLOCK_BOOTTIME, &n); - return (n.tv_sec + (n.tv_nsec / 1000000000.0)); + return (n.tv_sec + (n.tv_nsec / (double) NSEC_PER_SEC)); } void log_uptime(void) { @@ -250,6 +251,7 @@ schedstat_next: _cleanup_fclose_ FILE *st = NULL; char t[32]; struct ps_struct *parent; + int r; ps->next_ps = new0(struct ps_struct, 1); if (!ps->next_ps) { @@ -309,7 +311,11 @@ schedstat_next: if (!sscanf(m, "%*s %*s %s", t)) continue; - ps->starttime = strtod(t, NULL) / 1000.0; + r = safe_atod(t, &ps->starttime); + if (r < 0) + continue; + + ps->starttime /= 1000.0; if (arg_show_cgroup) /* if this fails, that's OK */ @@ -393,7 +399,7 @@ schedstat_next: continue; ps->sample->next = new0(struct ps_sched_struct, 1); - if (!ps->sample) { + if (!ps->sample->next) { log_oom(); exit(EXIT_FAILURE); }