X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbootchart%2Fbootchart.c;h=f1b0e58c69ba53aebefe5ab878f116adc66c3ab0;hb=682cfdff697707dbe29c9c1907a7c8c452ffb397;hp=3d77bab129f5565c7bdb0f38fdcd027a78b81b0f;hpb=28989b63f5e3a959557000f21f3891af08be40f7;p=elogind.git diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index 3d77bab12..f1b0e58c6 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -28,6 +28,7 @@ #include "bootchart.h" +#include "util.h" double graph_start; double log_start; @@ -74,13 +75,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 +108,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 +230,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));