[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241101110539.7046-1-kirjanov@gmail.com>
Date: Fri, 1 Nov 2024 14:05:39 +0300
From: Denis Kirjanov <kirjanov@...il.com>
To: stephen@...workplumber.org,
dsahern@...nel.org
Cc: netdev@...r.kernel.org,
Denis Kirjanov <kirjanov@...il.com>
Subject: [iproute2-next] ifstat: handle fclose errors
fclose() can fail so print an error
Signed-off-by: Denis Kirjanov <kirjanov@...il.com>
---
misc/ifstat.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/misc/ifstat.c b/misc/ifstat.c
index faebe938..b0c1ef10 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -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);
}
--
2.43.0
Powered by blists - more mailing lists