diff options
author | ed <ed@FreeBSD.org> | 2012-01-02 12:12:10 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-01-02 12:12:10 +0000 |
commit | ab210c8f2f4f0cd4839d93f66181fc7ad57ce8a9 (patch) | |
tree | c3375fb3aa9ccc6f33c26a511457552dfbab74a7 /sys/kern | |
parent | d9de01105e6c2f60ef0fb2a67c0f3d915cef8c61 (diff) | |
download | FreeBSD-src-ab210c8f2f4f0cd4839d93f66181fc7ad57ce8a9.zip FreeBSD-src-ab210c8f2f4f0cd4839d93f66181fc7ad57ce8a9.tar.gz |
Use strchr() and strrchr().
It seems strchr() and strrchr() are used more often than index() and
rindex(). Therefore, simply migrate all kernel code to use it.
For the XFS code, remove an empty line to make the code identical to
the code in the Linux kernel.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_intr.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_ktr.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_linker.c | 6 | ||||
-rw-r--r-- | sys/kern/subr_hints.c | 11 | ||||
-rw-r--r-- | sys/kern/tty_inq.c | 2 | ||||
-rw-r--r-- | sys/kern/uipc_mqueue.c | 4 |
6 files changed, 18 insertions, 19 deletions
diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index b9ed881..ced3261 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -693,9 +693,9 @@ intr_event_describe_handler(struct intr_event *ie, void *cookie, * description at that point. If one is not found, find the * end of the name to use as the insertion point. */ - start = index(ih->ih_name, ':'); + start = strchr(ih->ih_name, ':'); if (start == NULL) - start = index(ih->ih_name, 0); + start = strchr(ih->ih_name, 0); /* * See if there is enough remaining room in the string for the @@ -1832,8 +1832,8 @@ DB_SHOW_COMMAND(intr, db_show_intr) struct intr_event *ie; int all, verbose; - verbose = index(modif, 'v') != NULL; - all = index(modif, 'a') != NULL; + verbose = strchr(modif, 'v') != NULL; + all = strchr(modif, 'a') != NULL; TAILQ_FOREACH(ie, &event_list, ie_list) { if (!all && TAILQ_EMPTY(&ie->ie_handlers)) continue; diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 004a19e..60bc9c8 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -341,9 +341,9 @@ DB_SHOW_COMMAND(ktr, db_ktr_all) tstate.cur = (ktr_idx - 1) & (KTR_ENTRIES - 1); tstate.first = -1; db_ktr_verbose = 0; - db_ktr_verbose |= (index(modif, 'v') != NULL) ? 2 : 0; - db_ktr_verbose |= (index(modif, 'V') != NULL) ? 1 : 0; /* just timestap please */ - if (index(modif, 'a') != NULL) { + db_ktr_verbose |= (strchr(modif, 'v') != NULL) ? 2 : 0; + db_ktr_verbose |= (strchr(modif, 'V') != NULL) ? 1 : 0; /* just timestap please */ + if (strchr(modif, 'a') != NULL) { db_disable_pager(); while (cncheckc() != -1) if (db_mach_vtrace() == 0) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index d7e5ade..74fe19f 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1013,7 +1013,7 @@ kern_kldload(struct thread *td, const char *file, int *fileid) * (kldname.ko, or kldname.ver.ko) treat it as an interface * name. */ - if (index(file, '/') || index(file, '.')) { + if (strchr(file, '/') || strchr(file, '.')) { kldname = file; modname = NULL; } else { @@ -1906,7 +1906,7 @@ linker_search_kld(const char *name) int len; /* qualified at all? */ - if (index(name, '/')) + if (strchr(name, '/')) return (linker_strdup(name)); /* traverse the linker path */ @@ -1927,7 +1927,7 @@ linker_basename(const char *path) { const char *filename; - filename = rindex(path, '/'); + filename = strrchr(path, '/'); if (filename == NULL) return path; if (filename[1]) diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index a46b938..afa959d 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -133,8 +133,7 @@ res_find(int *line, int *startln, r_name, &r_unit, r_resname, r_value); if (hit && n != 4) { printf("CONFIG: invalid hint '%s'\n", cp); - /* XXX: abuse bogus index() declaration */ - p = index(cp, 'h'); + p = strchr(cp, 'h'); *p = 'H'; hit = 0; } @@ -172,18 +171,18 @@ res_find(int *line, int *startln, s = cp; /* This is a bit of a hack, but at least is reentrant */ /* Note that it returns some !unterminated! strings. */ - s = index(s, '.') + 1; /* start of device */ + s = strchr(s, '.') + 1; /* start of device */ if (ret_name) *ret_name = s; - s = index(s, '.') + 1; /* start of unit */ + s = strchr(s, '.') + 1; /* start of unit */ if (ret_namelen && ret_name) *ret_namelen = s - *ret_name - 1; /* device length */ if (ret_unit) *ret_unit = r_unit; - s = index(s, '.') + 1; /* start of resname */ + s = strchr(s, '.') + 1; /* start of resname */ if (ret_resname) *ret_resname = s; - s = index(s, '=') + 1; /* start of value */ + s = strchr(s, '=') + 1; /* start of value */ if (ret_resnamelen && ret_resname) *ret_resnamelen = s - *ret_resname - 1; /* value len */ if (ret_value) diff --git a/sys/kern/tty_inq.c b/sys/kern/tty_inq.c index 0c39a29..97017ac 100644 --- a/sys/kern/tty_inq.c +++ b/sys/kern/tty_inq.c @@ -355,7 +355,7 @@ ttyinq_findchar(struct ttyinq *ti, const char *breakc, size_t maxlen, return (0); while (boff < bend) { - if (index(breakc, tib->tib_data[boff]) && !GETBIT(tib, boff)) { + if (strchr(breakc, tib->tib_data[boff]) && !GETBIT(tib, boff)) { *lastc = tib->tib_data[boff]; return (boff - ti->ti_begin + 1); } diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index 696f974..212daba 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -1974,7 +1974,7 @@ kern_kmq_open(struct thread *td, const char *upath, int flags, mode_t mode, * characters. */ len = strlen(path); - if (len < 2 || path[0] != '/' || index(path + 1, '/') != NULL) + if (len < 2 || path[0] != '/' || strchr(path + 1, '/') != NULL) return (EINVAL); error = falloc(td, &fp, &fd, 0); @@ -2077,7 +2077,7 @@ sys_kmq_unlink(struct thread *td, struct kmq_unlink_args *uap) return (error); len = strlen(path); - if (len < 2 || path[0] != '/' || index(path + 1, '/') != NULL) + if (len < 2 || path[0] != '/' || strchr(path + 1, '/') != NULL) return (EINVAL); sx_xlock(&mqfs_data.mi_lock); |