X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbootchart%2Fbootchart.c;h=6b9252dbb982043de65983ce76c85e369b9519a5;hb=cd3bccaaf7b3c0e000cfd1bac638a52cb4f510c3;hp=3d77bab129f5565c7bdb0f38fdcd027a78b81b0f;hpb=28989b63f5e3a959557000f21f3891af08be40f7;p=elogind.git diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index 3d77bab12..6b9252dbb 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -1,17 +1,24 @@ -/* - * bootchart.c - * - * Copyright (C) 2009-2012 Intel Coproration - * - * Authors: - * Auke Kok - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; version 2 - * of the License. - */ +/*** + bootchart.c - This file is part of systemd-bootchart + Copyright (C) 2009-2013 Intel Coproration + + Authors: + Auke Kok + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . + ***/ #include #include @@ -28,6 +35,7 @@ #include "bootchart.h" +#include "util.h" double graph_start; double log_start; @@ -74,13 +82,11 @@ int main(int argc, char *argv[]) struct ps_struct *ps; char output_file[PATH_MAX]; char datestr[200]; - time_t t; + time_t t = 0; FILE *f; int gind; int i; - memset(&t, 0, sizeof(time_t)); - rlim.rlim_cur = 4096; rlim.rlim_max = 4096; (void) setrlimit(RLIMIT_NOFILE, &rlim); @@ -109,25 +115,25 @@ int main(int argc, char *argv[]) // todo: filter leading/trailing whitespace - if (!strcmp(key, "samples")) + if (streq(key, "samples")) len = atoi(val); - if (!strcmp(key, "freq")) + if (streq(key, "freq")) hz = atof(val); - if (!strcmp(key, "rel")) + if (streq(key, "rel")) relative = atoi(val); - if (!strcmp(key, "filter")) + if (streq(key, "filter")) filter = atoi(val); - if (!strcmp(key, "pss")) + if (streq(key, "pss")) pss = atoi(val); - if (!strcmp(key, "output")) + if (streq(key, "output")) strncpy(output_path, val, PATH_MAX - 1); - if (!strcmp(key, "init")) + if (streq(key, "init")) strncpy(init_path, val, PATH_MAX - 1); - if (!strcmp(key, "scale_x")) + if (streq(key, "scale_x")) scale_x = atof(val); - if (!strcmp(key, "scale_y")) + if (streq(key, "scale_y")) scale_y = atof(val); - if (!strcmp(key, "entropy")) + if (streq(key, "entropy")) entropy = atoi(val); } fclose(f); @@ -231,12 +237,11 @@ int main(int argc, char *argv[]) } /* start with empty ps LL */ - ps_first = malloc(sizeof(struct ps_struct)); + ps_first = calloc(1, sizeof(struct ps_struct)); if (!ps_first) { - perror("malloc(ps_struct)"); + perror("calloc(ps_struct)"); exit(EXIT_FAILURE); } - memset(ps_first, 0, sizeof(struct ps_struct)); /* handle TERM/INT nicely */ memset(&sig, 0, sizeof(struct sigaction));