summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
committered <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
commite7e5b53bf16ab3b35646f0580b36fa7d7afa9678 (patch)
treeb751618c7a82d9c00cab91ea9f611585dbf14d84 /sbin
parentd106f2fd7cf6be7617b1756d893b5b6fba5310f4 (diff)
downloadFreeBSD-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 'sbin')
-rw-r--r--sbin/bsdlabel/bsdlabel.c4
-rw-r--r--sbin/dump/main.c2
-rw-r--r--sbin/fsck_ffs/pass2.c2
-rw-r--r--sbin/ipfw/main.c10
-rw-r--r--sbin/shutdown/shutdown.c2
5 files changed, 10 insertions, 10 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 2dcffd0..a7cc2a2 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -782,12 +782,12 @@ getasciilabel(FILE *f, struct disklabel *lp)
lp->d_sbsize = 0; /* XXX */
while (fgets(line, sizeof(line) - 1, f)) {
lineno++;
- if ((cp = index(line,'\n')) != 0)
+ if ((cp = strchr(line,'\n')) != 0)
*cp = '\0';
cp = skip(line);
if (cp == NULL)
continue;
- tp = index(cp, ':');
+ tp = strchr(cp, ':');
if (tp == NULL) {
fprintf(stderr, "line %d: syntax error\n", lineno);
errors++;
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 3e6ed1f..3ec78fd1 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -290,7 +290,7 @@ main(int argc, char *argv[])
tape = strchr(host, ':');
*tape++ = '\0';
#ifdef RDUMP
- if (index(tape, '\n')) {
+ if (strchr(tape, '\n')) {
(void)fprintf(stderr, "invalid characters in tape\n");
exit(X_STARTUP);
}
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 5959778..bd9bf97 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -613,7 +613,7 @@ fix_extraneous(struct inoinfo *inp, struct inodesc *idesc)
printf(" (IGNORED)\n");
return (0);
}
- if ((cp = rindex(oldname, '/')) == NULL) {
+ if ((cp = strchr(oldname, '/')) == NULL) {
printf(" (IGNORED)\n");
return (0);
}
diff --git a/sbin/ipfw/main.c b/sbin/ipfw/main.c
index 337d545..debed4e 100644
--- a/sbin/ipfw/main.c
+++ b/sbin/ipfw/main.c
@@ -122,9 +122,9 @@ ipfw_main(int oldac, char **oldav)
break;
if (copy) {
arg[j++] = arg[i];
- copy = !index("," WHITESP, arg[i]);
+ copy = !strchr("," WHITESP, arg[i]);
} else {
- copy = !index(WHITESP, arg[i]);
+ copy = !strchr(WHITESP, arg[i]);
if (copy)
arg[j++] = arg[i];
}
@@ -141,7 +141,7 @@ ipfw_main(int oldac, char **oldav)
* processing, this is just the number of blanks plus 1.
*/
for (i = 0, ac = 1; i < l; i++)
- if (index(WHITESP, arg[i]) != NULL)
+ if (strchr(WHITESP, arg[i]) != NULL)
ac++;
/*
@@ -162,7 +162,7 @@ ipfw_main(int oldac, char **oldav)
*/
av_p = (char *)&av[ac+1];
for (ac = 1, i = j = 0; i < l; i++) {
- if (index(WHITESP, arg[i]) != NULL || i == l-1) {
+ if (strchr(WHITESP, arg[i]) != NULL || i == l-1) {
if (i == l-1)
i++;
bcopy(arg+j, av_p, i-j);
@@ -240,7 +240,7 @@ ipfw_main(int oldac, char **oldav)
" ipfw sysctl -a\n");
return 0;
}
- s = index(av[2], '=');
+ s = strchr(av[2], '=');
if (s == NULL) {
s = !strcmp(av[2], "-a") ? NULL : av[2];
sysctlbyname(s, NULL, NULL, NULL, 0);
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 7bd93a0..6e662a8 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -123,7 +123,7 @@ main(int argc, char **argv)
* Test for the special case where the utility is called as
* "poweroff", for which it runs 'shutdown -p now'.
*/
- if ((p = rindex(argv[0], '/')) == NULL)
+ if ((p = strrchr(argv[0], '/')) == NULL)
p = argv[0];
else
++p;
OpenPOWER on IntegriCloud