diff options
author | Phil Sutter <phil@nwl.cc> | 2015-11-28 01:00:05 +0100 |
---|---|---|
committer | Stephen Hemminger <shemming@brocade.com> | 2015-11-29 11:48:24 -0800 |
commit | 61170fd88d264c6a6c9d2c2f4433cdacc3385e93 (patch) | |
tree | c51d894e133b3d64fa534cf64f1caf5f0bb7e97c | |
parent | d572ed4d0af79eb597469d3f1a84456782c64f24 (diff) | |
download | android_external_iproute2-61170fd88d264c6a6c9d2c2f4433cdacc3385e93.tar.gz android_external_iproute2-61170fd88d264c6a6c9d2c2f4433cdacc3385e93.tar.bz2 android_external_iproute2-61170fd88d264c6a6c9d2c2f4433cdacc3385e93.zip |
get rid of unnecessary fgets() buffer size limitation
fgets() will read at most size-1 bytes into the buffer and add a
terminating null-char at the end. Therefore it is not necessary to pass
a reduced buffer size when calling it.
This change was generated using the following semantic patch:
@@
identifier buf, fp;
@@
- fgets(buf, sizeof(buf) - 1, fp)
+ fgets(buf, sizeof(buf), fp)
Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r-- | misc/arpd.c | 2 | ||||
-rw-r--r-- | misc/ss.c | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/misc/arpd.c b/misc/arpd.c index 7919eb8..6bb9bd1 100644 --- a/misc/arpd.c +++ b/misc/arpd.c @@ -703,7 +703,7 @@ int main(int argc, char **argv) } buf[sizeof(buf)-1] = 0; - while (fgets(buf, sizeof(buf)-1, fp)) { + while (fgets(buf, sizeof(buf), fp)) { __u8 b1[6]; char ipbuf[128]; char macbuf[128]; @@ -2729,7 +2729,7 @@ static int unix_show(struct filter *f) if ((fp = net_unix_open()) == NULL) return -1; - if (!fgets(buf, sizeof(buf)-1, fp)) { + if (!fgets(buf, sizeof(buf), fp)) { fclose(fp); return -1; } @@ -2738,7 +2738,7 @@ static int unix_show(struct filter *f) newformat = 1; cnt = 0; - while (fgets(buf, sizeof(buf)-1, fp)) { + while (fgets(buf, sizeof(buf), fp)) { struct sockstat *u, **insp; int flags; @@ -3217,12 +3217,12 @@ static int netlink_show(struct filter *f) if ((fp = net_netlink_open()) == NULL) return -1; - if (!fgets(buf, sizeof(buf)-1, fp)) { + if (!fgets(buf, sizeof(buf), fp)) { fclose(fp); return -1; } - while (fgets(buf, sizeof(buf)-1, fp)) { + while (fgets(buf, sizeof(buf), fp)) { sscanf(buf, "%llx %d %d %x %d %d %llx %d", &sk, &prot, &pid, &groups, &rq, &wq, &cb, &rc); |