]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ifstat: handle unlink return value
authorDenis Kirjanov <kirjanov@gmail.com>
Thu, 29 Feb 2024 12:26:34 +0000 (07:26 -0500)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 4 Mar 2024 01:12:11 +0000 (17:12 -0800)
Print an error message if we can't remove the history file

v2: exit if unlink failed
v3: restore the changelog

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
misc/ifstat.c

index 767cedd4aa475a33a29bdc5485e9253ace36df28..72901097e6c2f844cc7a4ae7e25a9ef6068dde1d 100644 (file)
@@ -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;