Message ID | 20240221120424.3221-1-dkirjanov@suse.de (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Stephen Hemminger |
Headers | show |
Series | [iproute2] ifstat: handle unlink return value | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Wed, 21 Feb 2024 07:04:24 -0500 Denis Kirjanov <kirjanov@gmail.com> wrote: > Print an error message if we can't remove the history file > > Signed-off-by: Denis Kirjanov <dkirjanov@suse.de> > --- Good idea, but would like the output and result to look like the other errors in ifstat about history file. Something like: diff --git a/misc/ifstat.c b/misc/ifstat.c index 767cedd4aa47..72901097e6c2 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -937,8 +937,10 @@ int main(int argc, char *argv[]) "%s/.%s_ifstat.u%d", P_tmpdir, stats_type, getuid()); - if (reset_history) - unlink(hist_name); + if (reset_history && unlink(hist_name) < 0) { + perror("ifstat: unlink history file"); + exit(-1); + } if (!ignore_history || !no_update) { struct stat stb;
diff --git a/misc/ifstat.c b/misc/ifstat.c index 18171a2c..5dede111 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -938,7 +938,9 @@ int main(int argc, char *argv[]) getuid()); if (reset_history) - unlink(hist_name); + if (unlink(hist_name) < 0) + fprintf(stderr, "Cannot remove history file \"%s\": %s\n", + hist_name, strerror(errno)); if (!ignore_history || !no_update) { struct stat stb;
Print an error message if we can't remove the history file Signed-off-by: Denis Kirjanov <dkirjanov@suse.de> --- misc/ifstat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)