aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/bootchartd.c
diff options
context:
space:
mode:
authorAshwini Sharma <ak.ashwini1981.gmail.com>2014-09-18 11:47:42 -0500
committerAshwini Sharma <ak.ashwini1981.gmail.com>2014-09-18 11:47:42 -0500
commit14a11ed5ebfb2309a3fdfea1ce7a741519e44693 (patch)
tree0f9b4170a6169cece9f5ea4e7aa85ce34fe011c8 /toys/pending/bootchartd.c
parent40b20421e42cce9834d13ab52ac58efd78838ede (diff)
downloadtoybox-14a11ed5ebfb2309a3fdfea1ce7a741519e44693.tar.gz
A few fixes for issues reported in static analysis.
Diffstat (limited to 'toys/pending/bootchartd.c')
-rw-r--r--toys/pending/bootchartd.c14
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);