aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
committerEd Schouten <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
commitb3608ae18f1e5598bed81d0a10dd585a5080c40d (patch)
treeb751618c7a82d9c00cab91ea9f611585dbf14d84 /usr.bin/systat
parent69ee3e2f52eb8cba6e103cd1de3f91a7ffe1ddc7 (diff)
downloadsrc-b3608ae18f1e5598bed81d0a10dd585a5080c40d.tar.gz
src-b3608ae18f1e5598bed81d0a10dd585a5080c40d.zip
Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls.
Notes
Notes: svn path=/head/; revision=229403
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/devs.c2
-rw-r--r--usr.bin/systat/netcmds.c2
-rw-r--r--usr.bin/systat/netstat.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c
index 09a18384c8cb..3c74fb7690e3 100644
--- a/usr.bin/systat/devs.c
+++ b/usr.bin/systat/devs.c
@@ -265,7 +265,7 @@ dsselect(const char *args, devstat_select_mode select_mode, int maxshowdevs,
specified_devices = (char **)malloc(sizeof(char *));
tmpstr = tmpstr1 = strdup(args);
- cp = index(tmpstr1, '\n');
+ cp = strchr(tmpstr1, '\n');
if (cp)
*cp = '\0';
for (;;) {
diff --git a/usr.bin/systat/netcmds.c b/usr.bin/systat/netcmds.c
index c7f1178df4fb..e627329cda5f 100644
--- a/usr.bin/systat/netcmds.c
+++ b/usr.bin/systat/netcmds.c
@@ -131,7 +131,7 @@ changeitems(const char *args, int onoff)
struct in_addr in;
tmpstr = tmpstr1 = strdup(args);
- cp = index(tmpstr1, '\n');
+ cp = strchr(tmpstr1, '\n');
if (cp)
*cp = '\0';
for (;;tmpstr1 = cp) {
diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c
index d96fb16082bb..a5e06083c1f6 100644
--- a/usr.bin/systat/netstat.c
+++ b/usr.bin/systat/netstat.c
@@ -554,7 +554,7 @@ inetprint(struct sockaddr *sa, const char *proto)
break;
}
snprintf(line, sizeof(line), "%.*s.", 16, inetname(sa));
- cp = index(line, '\0');
+ cp = strchr(line, '\0');
if (!nflag && port)
sp = getservbyport(port, proto);
if (sp || port == 0)
@@ -564,7 +564,7 @@ inetprint(struct sockaddr *sa, const char *proto)
snprintf(cp, sizeof(line) - (cp - line), "%d",
ntohs((u_short)port));
/* pad to full column to clear any garbage */
- cp = index(line, '\0');
+ cp = strchr(line, '\0');
while (cp - line < 22)
*cp++ = ' ';
line[22] = '\0';