diff options
author | ed <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
commit | e7e5b53bf16ab3b35646f0580b36fa7d7afa9678 (patch) | |
tree | b751618c7a82d9c00cab91ea9f611585dbf14d84 /usr.bin/netstat | |
parent | d106f2fd7cf6be7617b1756d893b5b6fba5310f4 (diff) | |
download | FreeBSD-src-e7e5b53bf16ab3b35646f0580b36fa7d7afa9678.zip FreeBSD-src-e7e5b53bf16ab3b35646f0580b36fa7d7afa9678.tar.gz |
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.
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r-- | usr.bin/netstat/if.c | 2 | ||||
-rw-r--r-- | usr.bin/netstat/inet.c | 2 | ||||
-rw-r--r-- | usr.bin/netstat/inet6.c | 6 | ||||
-rw-r--r-- | usr.bin/netstat/sctp.c | 6 |
4 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 8a11270..a985791 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -256,7 +256,7 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *)) ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_link); if (interface != 0 && strcmp(name, interface) != 0) continue; - cp = index(name, '\0'); + cp = strchr(name, '\0'); if (pfunc) { (*pfunc)(name); diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 1653018..7309951 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1247,7 +1247,7 @@ inetprint(struct in_addr *in, int port, const char *proto, int num_port) sprintf(line, "%s.", inetname(in)); else sprintf(line, "%.*s.", (Aflag && !num_port) ? 12 : 16, inetname(in)); - cp = index(line, '\0'); + cp = strchr(line, '\0'); if (!num_port && port) sp = getservbyport((int)port, proto); if (sp || port == 0) diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index 03fef6e..1a19fa5 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -1100,7 +1100,7 @@ inet6print(struct in6_addr *in6, int port, const char *proto, int numeric) sprintf(line, "%.*s.", Wflag ? 39 : (Aflag && !numeric) ? 12 : 16, inet6name(in6)); - cp = index(line, '\0'); + cp = strchr(line, '\0'); if (!numeric && port) GETSERVBYPORT6(port, proto, sp); if (sp || port == 0) @@ -1129,7 +1129,7 @@ inet6name(struct in6_addr *in6p) if (first && !numeric_addr) { first = 0; if (gethostname(domain, MAXHOSTNAMELEN) == 0 && - (cp = index(domain, '.'))) + (cp = strchr(domain, '.'))) (void) strcpy(domain, cp + 1); else domain[0] = 0; @@ -1138,7 +1138,7 @@ inet6name(struct in6_addr *in6p) if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) { hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6); if (hp) { - if ((cp = index(hp->h_name, '.')) && + if ((cp = strchr(hp->h_name, '.')) && !strcmp(cp + 1, domain)) *cp = 0; cp = hp->h_name; diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c index d5ad70e..fb94d44 100644 --- a/usr.bin/netstat/sctp.c +++ b/usr.bin/netstat/sctp.c @@ -162,7 +162,7 @@ inet6name(struct in6_addr *in6p) if (first && !numeric_addr) { first = 0; if (gethostname(domain, MAXHOSTNAMELEN) == 0 && - (cp = index(domain, '.'))) + (cp = strchr(domain, '.'))) (void) strcpy(domain, cp + 1); else domain[0] = 0; @@ -171,7 +171,7 @@ inet6name(struct in6_addr *in6p) if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) { hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6); if (hp) { - if ((cp = index(hp->h_name, '.')) && + if ((cp = strchr(hp->h_name, '.')) && !strcmp(cp + 1, domain)) *cp = 0; cp = hp->h_name; @@ -209,7 +209,7 @@ sctp_print_address(union sctp_sockstore *address, int port, int num_port) sprintf(line, "%.*s.", Wflag ? 39 : 16, ""); break; } - cp = index(line, '\0'); + cp = strchr(line, '\0'); if (!num_port && port) sp = getservbyport((int)port, "sctp"); if (sp || port == 0) |