]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
get rid of remaining -Wunused-result warnings
authorPhil Sutter <phil@nwl.cc>
Sat, 28 Nov 2015 00:00:04 +0000 (01:00 +0100)
committerStephen Hemminger <shemming@brocade.com>
Sun, 29 Nov 2015 19:48:24 +0000 (11:48 -0800)
Although not fundamentally necessary to check return codes in these
spots, preventing the warnings will put new ones into focus.

Signed-off-by: Phil Sutter <phil@nwl.cc>
misc/ifstat.c
misc/lnstat_util.c
misc/nstat.c
misc/ss.c

index 20a8db45985be1939adc6eabb3e67df34fb3eca2..ac5c29c89184ab9dbd3029e6bf0c9414e77c7635 100644 (file)
@@ -819,7 +819,8 @@ int main(int argc, char *argv[])
                        }
                        if (uptime >= 0 && time(NULL) >= stb.st_mtime+uptime) {
                                fprintf(stderr, "ifstat: history is aged out, resetting\n");
-                               ftruncate(fileno(hist_fp), 0);
+                               if (ftruncate(fileno(hist_fp), 0))
+                                       perror("ifstat: ftruncate");
                        }
                }
 
@@ -862,7 +863,8 @@ int main(int argc, char *argv[])
        }
 
        if (!no_update) {
-               ftruncate(fileno(hist_fp), 0);
+               if (ftruncate(fileno(hist_fp), 0))
+                       perror("ifstat: ftruncate");
                rewind(hist_fp);
 
                json_output = 0;
index 433e992976eac630c1858f7c1040aaa8c7cee633..70a77c5649f9b34b71a6ec7b7ae66e85fee57cf1 100644 (file)
@@ -138,7 +138,8 @@ static int lnstat_scan_fields(struct lnstat_file *lf)
        char buf[FGETS_BUF_SIZE];
 
        rewind(lf->fp);
-       fgets(buf, sizeof(buf)-1, lf->fp);
+       if (!fgets(buf, sizeof(buf)-1, lf->fp))
+               return -1;
 
        return __lnstat_scan_fields(lf, buf);
 }
index 267e515ff987cf1e05b0612a67e3e7631a1f5bcb..99705286d279cb47d2a12a78fac23851a5f0082e 100644 (file)
@@ -649,7 +649,8 @@ int main(int argc, char *argv[])
                        }
                        if (uptime >= 0 && time(NULL) >= stb.st_mtime+uptime) {
                                fprintf(stderr, "nstat: history is aged out, resetting\n");
-                               ftruncate(fileno(hist_fp), 0);
+                               if (ftruncate(fileno(hist_fp), 0) < 0)
+                                       perror("nstat: ftruncate");
                        }
                }
 
@@ -693,7 +694,8 @@ int main(int argc, char *argv[])
                        dump_incr_db(stdout);
        }
        if (!no_update) {
-               ftruncate(fileno(hist_fp), 0);
+               if (ftruncate(fileno(hist_fp), 0) < 0)
+                       perror("nstat: ftruncate");
                rewind(hist_fp);
 
                json_output = 0;
index 7928573285e4ea3326ebef76c442c8e0207e5f6c..d509009429de175fbc2f7ce02baa11496ad3abf0 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -528,7 +528,8 @@ static void user_ent_hash_build(void)
                                snprintf(tmp, sizeof(tmp), "%s/%d/stat",
                                        root, pid);
                                if ((fp = fopen(tmp, "r")) != NULL) {
-                                       fscanf(fp, "%*d (%[^)])", p);
+                                       if (fscanf(fp, "%*d (%[^)])", p) < 1)
+                                               ; /* ignore */
                                        fclose(fp);
                                }
                        }
@@ -660,7 +661,10 @@ static int get_slabstat(struct slabstat *s)
 
        cnt = sizeof(*s)/sizeof(int);
 
-       fgets(buf, sizeof(buf), fp);
+       if (!fgets(buf, sizeof(buf), fp)) {
+               fclose(fp);
+               return -1;
+       }
        while(fgets(buf, sizeof(buf), fp) != NULL) {
                int i;
                for (i=0; i<sizeof(slabstat_ids)/sizeof(slabstat_ids[0]); i++) {
@@ -2725,7 +2729,10 @@ static int unix_show(struct filter *f)
 
        if ((fp = net_unix_open()) == NULL)
                return -1;
-       fgets(buf, sizeof(buf)-1, fp);
+       if (!fgets(buf, sizeof(buf)-1, fp)) {
+               fclose(fp);
+               return -1;
+       }
 
        if (memcmp(buf, "Peer", 4) == 0)
                newformat = 1;
@@ -3210,7 +3217,10 @@ static int netlink_show(struct filter *f)
 
        if ((fp = net_netlink_open()) == NULL)
                return -1;
-       fgets(buf, sizeof(buf)-1, fp);
+       if (!fgets(buf, sizeof(buf)-1, fp)) {
+               fclose(fp);
+               return -1;
+       }
 
        while (fgets(buf, sizeof(buf)-1, fp)) {
                sscanf(buf, "%llx %d %d %x %d %d %llx %d",