diff options
Diffstat (limited to 'toys/pending/bootchartd.c')
-rw-r--r-- | toys/pending/bootchartd.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/toys/pending/bootchartd.c b/toys/pending/bootchartd.c index cbed4ac0..72ade69c 100644 --- a/toys/pending/bootchartd.c +++ b/toys/pending/bootchartd.c @@ -82,7 +82,10 @@ static int dump_proc_data(FILE *fp) char *ptr; ssize_t len; - if ((len = readall(fd, toybuf, sizeof(toybuf)-1)) < 0) continue; + if ((len = readall(fd, toybuf, sizeof(toybuf)-1)) < 0) { + xclose(fd); + continue; + } toybuf[len] = '\0'; close(fd); fputs(toybuf, fp); @@ -226,10 +229,11 @@ static void stop_logging(char *tmp_dir, char *prog) if ((kcmd_line_fd = open("/proc/cmdline", O_RDONLY)) != -1) { ssize_t len; - len = readall(kcmd_line_fd, toybuf, sizeof(toybuf)-1); - toybuf[len] = 0; - while (--len >= 0 && !toybuf[len]) continue; - for (; len > 0; len--) if (toybuf[len] < ' ') toybuf[len] = ' '; + if ((len = readall(kcmd_line_fd, toybuf, sizeof(toybuf)-1)) > 0) { + toybuf[len] = 0; + while (--len >= 0 && !toybuf[len]) continue; + for (; len > 0; len--) if (toybuf[len] < ' ') toybuf[len] = ' '; + } else *toybuf = 0; } fprintf(hdr_fp, "system.kernel.options = %s", toybuf); close(kcmd_line_fd); |