diff options
author | Phil Sutter <phil@nwl.cc> | 2015-11-28 01:00:04 +0100 |
---|---|---|
committer | Stephen Hemminger <shemming@brocade.com> | 2015-11-29 11:48:24 -0800 |
commit | d572ed4d0af79eb597469d3f1a84456782c64f24 (patch) | |
tree | 21a3d0fd98c165043932c7496376035fa5d1687a | |
parent | c29d37925aa479a6c0545fee87329ab1d248680a (diff) | |
download | android_external_iproute2-d572ed4d0af79eb597469d3f1a84456782c64f24.tar.gz android_external_iproute2-d572ed4d0af79eb597469d3f1a84456782c64f24.tar.bz2 android_external_iproute2-d572ed4d0af79eb597469d3f1a84456782c64f24.zip |
get rid of remaining -Wunused-result warnings
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>
-rw-r--r-- | misc/ifstat.c | 6 | ||||
-rw-r--r-- | misc/lnstat_util.c | 3 | ||||
-rw-r--r-- | misc/nstat.c | 6 | ||||
-rw-r--r-- | misc/ss.c | 18 |
4 files changed, 24 insertions, 9 deletions
diff --git a/misc/ifstat.c b/misc/ifstat.c index 20a8db4..ac5c29c 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -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; diff --git a/misc/lnstat_util.c b/misc/lnstat_util.c index 433e992..70a77c5 100644 --- a/misc/lnstat_util.c +++ b/misc/lnstat_util.c @@ -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); } diff --git a/misc/nstat.c b/misc/nstat.c index 267e515..9970528 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -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; @@ -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", |