@@ -1003,7 +1003,8 @@ int main(int argc, char *argv[])
if ((tfp = fopen("/proc/uptime", "r")) != NULL) {
if (fscanf(tfp, "%ld", &uptime) != 1)
uptime = -1;
- fclose(tfp);
+ if (fclose(tfp))
+ perror("ifstat: fclose");
}
if (uptime >= 0 && time(NULL) >= stb.st_mtime+uptime) {
fprintf(stderr, "ifstat: history is aged out, resetting\n");
@@ -1035,7 +1036,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "ifstat: history is stale, ignoring it.\n");
hist_db = NULL;
}
- fclose(sfp);
+ if (fclose(sfp))
+ perror("ifstat: fclose");
}
} else {
if (fd >= 0)
@@ -1064,7 +1066,8 @@ int main(int argc, char *argv[])
json_output = 0;
dump_raw_db(hist_fp, 1);
- fclose(hist_fp);
+ if (fclose(hist_fp))
+ perror("ifstat: fclose");
}
exit(0);
}
fclose() can fail so print an error Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> --- misc/ifstat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)