diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c index 39f2da7bd908..171b3dac0a36 100644 --- a/sys/ddb/db_input.c +++ b/sys/ddb/db_input.c @@ -253,7 +253,7 @@ db_inputchar(c) db_putnchars(BACKUP, db_lc - db_lbuf_start); db_putnchars(BLANK, db_le - db_lbuf_start); db_putnchars(BACKUP, db_le - db_lbuf_start); - db_le = index(db_lbuf_start, '\0'); + db_le = strchr(db_lbuf_start, '\0'); if (db_le[-1] == '\r' || db_le[-1] == '\n') *--db_le = '\0'; db_lc = db_le; diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index a45221a3c3f4..538834920984 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -532,8 +532,8 @@ ad_describe(device_t dev) u_int8_t *marker, vendor[64], product[64]; /* try to separate the ATA model string into vendor and model parts */ - if ((marker = index(atadev->param.model, ' ')) || - (marker = index(atadev->param.model, '-'))) { + if ((marker = strchr(atadev->param.model, ' ')) || + (marker = strchr(atadev->param.model, '-'))) { int len = (marker - atadev->param.model); strncpy(vendor, atadev->param.model, len); diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c index 23af28635d64..a33d03f7bbc6 100644 --- a/sys/dev/mxge/if_mxge.c +++ b/sys/dev/mxge/if_mxge.c @@ -2827,7 +2827,7 @@ mxge_media_init(mxge_softc_t *sc) } for (i = 0; i < 3; i++, ptr++) { - ptr = index(ptr, '-'); + ptr = strchr(ptr, '-'); if (ptr == NULL) { device_printf(sc->dev, "only %d dashes in PC?!?\n", i); diff --git a/sys/dev/uart/uart_cpu_sparc64.c b/sys/dev/uart/uart_cpu_sparc64.c index 582e919c9955..6cbfbe20858c 100644 --- a/sys/dev/uart/uart_cpu_sparc64.c +++ b/sys/dev/uart/uart_cpu_sparc64.c @@ -71,7 +71,7 @@ uart_cpu_channel(char *dev) if ((aliases = OF_finddevice("/aliases")) != -1) (void)OF_getprop(aliases, dev, alias, sizeof(alias)); len = strlen(alias); - if ((p = rindex(alias, ':')) == NULL) + if ((p = strrchr(alias, ':')) == NULL) return (0); p++; if (p - alias == len - 1 && (*p == 'a' || *p == 'b')) diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index 726d3b5afadf..763e2bd9f1ce 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -712,7 +712,7 @@ MALLOC_DECLARE(M_NEWNFSDROLLBACK); /* * Set this macro to index() or strchr(), whichever is supported. */ -#define STRCHR(s, c) index((s), (c)) +#define STRCHR(s, c) strchr((s), (c)) /* * Set the n_time in the client write rpc, as required. diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c index c20159f5cd8e..697f9d1221b5 100644 --- a/sys/fs/nwfs/nwfs_vfsops.c +++ b/sys/fs/nwfs/nwfs_vfsops.c @@ -206,10 +206,10 @@ static int nwfs_mount(struct mount *mp) pe = pc+sizeof(mp->mnt_stat.f_mntfromname); bzero(pc, MNAMELEN); *(pc++) = '/'; - pc = index(strncpy(pc, conn->li.server, pe-pc-2),0); + pc = strchr(strncpy(pc, conn->li.server, pe - pc - 2), 0); if (pc < pe-1) { *(pc++) = ':'; - pc=index(strncpy(pc, conn->li.user, pe-pc-2),0); + pc = strchr(strncpy(pc, conn->li.user, pe - pc - 2), 0); if (pc < pe-1) { *(pc++) = '/'; strncpy(pc, nmp->m.mounted_vol, pe-pc-2); diff --git a/sys/fs/smbfs/smbfs_vfsops.c b/sys/fs/smbfs/smbfs_vfsops.c index ac0c5e729c43..eb2e7f92418f 100644 --- a/sys/fs/smbfs/smbfs_vfsops.c +++ b/sys/fs/smbfs/smbfs_vfsops.c @@ -234,10 +234,10 @@ smbfs_mount(struct mount *mp) bzero(pc, MNAMELEN); *pc++ = '/'; *pc++ = '/'; - pc=index(strncpy(pc, vcp->vc_username, pe - pc - 2), 0); + pc = strchr(strncpy(pc, vcp->vc_username, pe - pc - 2), 0); if (pc < pe-1) { *(pc++) = '@'; - pc = index(strncpy(pc, vcp->vc_srvname, pe - pc - 2), 0); + pc = strchr(strncpy(pc, vcp->vc_srvname, pe - pc - 2), 0); if (pc < pe - 1) { *(pc++) = '/'; strncpy(pc, ssp->ss_name, pe - pc - 2); diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index 830c249e0067..a236ca764962 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -1039,7 +1039,7 @@ smbfs_pathcheck(struct smbmount *smp, const char *name, int nmlen, int nameiop) * Backslash characters, being a path delimiter, are prohibited * within a path component even for LOOKUP operations. */ - if (index(name, '\\') != NULL) + if (strchr(name, '\\') != NULL) return ENOENT; if (nameiop == LOOKUP) @@ -1051,20 +1051,20 @@ smbfs_pathcheck(struct smbmount *smp, const char *name, int nmlen, int nameiop) */ if (nmlen > 12) return ENAMETOOLONG; - cp = index(name, '.'); + cp = strchr(name, '.'); if (cp == NULL) return error; if (cp == name || (cp - name) > 8) return error; - cp = index(cp + 1, '.'); + cp = strchr(cp + 1, '.'); if (cp != NULL) return error; for (cp = name, i = 0; i < nmlen; i++, cp++) - if (index(badchars83, *cp) != NULL) + if (strchr(badchars83, *cp) != NULL) return error; } for (cp = name, i = 0; i < nmlen; i++, cp++) - if (index(badchars, *cp) != NULL) + if (strchr(badchars, *cp) != NULL) return error; return 0; } diff --git a/sys/gnu/fs/xfs/xfs_vfsops.c b/sys/gnu/fs/xfs/xfs_vfsops.c index 63d568b1d87b..e97a36399a0e 100644 --- a/sys/gnu/fs/xfs/xfs_vfsops.c +++ b/sys/gnu/fs/xfs/xfs_vfsops.c @@ -1743,8 +1743,7 @@ xfs_parseargs( while ((this_char = strsep(&options, ",")) != NULL) { if (!*this_char) continue; - - if ((value = index(this_char, '=')) != NULL) + if ((value = strchr(this_char, '=')) != NULL) *value++ = 0; if (!strcmp(this_char, MNTOPT_LOGBUFS)) { diff --git a/sys/i386/ibcs2/ibcs2_socksys.c b/sys/i386/ibcs2/ibcs2_socksys.c index ce96fc925e99..80b121614b8c 100644 --- a/sys/i386/ibcs2/ibcs2_socksys.c +++ b/sys/i386/ibcs2/ibcs2_socksys.c @@ -152,7 +152,7 @@ ibcs2_getipdomainname(td, uap) /* Get the domain name. */ getcredhostname(td->td_ucred, hname, sizeof(hname)); - dptr = index(hname, '.'); + dptr = strchr(hname, '.'); if ( dptr ) dptr++; else @@ -182,7 +182,7 @@ ibcs2_setipdomainname(td, uap) return EINVAL; /* Get the host's unqualified name (strip off the domain) */ - ptr = index(hname, '.'); + ptr = strchr(hname, '.'); if ( ptr != NULL ) { ptr++; *ptr = '\0'; diff --git a/sys/i386/ibcs2/ibcs2_stat.c b/sys/i386/ibcs2/ibcs2_stat.c index b61e45ef4bf5..c1097a320a5e 100644 --- a/sys/i386/ibcs2/ibcs2_stat.c +++ b/sys/i386/ibcs2/ibcs2_stat.c @@ -212,7 +212,7 @@ ibcs2_utssys(td, uap) IBCS2_UNAME_VERSION, sizeof(sut.version) - 1); getcredhostname(td->td_ucred, machine_name, sizeof(machine_name) - 1); - p = index(machine_name, '.'); + p = strchr(machine_name, '.'); if ( p ) *p = '\0'; strncpy(sut.nodename, machine_name, sizeof(sut.nodename) - 1); diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index b9ed881224b5..ced3261195fc 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 004a19ef4610..60bc9c8f66ef 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 d7e5ade1ca53..74fe19f036d9 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 a46b938ef37e..afa959d8d895 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 0c39a293dedd..97017ac75a41 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 696f9740dd1a..212dabafbf79 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); diff --git a/sys/libkern/fnmatch.c b/sys/libkern/fnmatch.c index d6cdc85ff6fd..5e7bda6ecec9 100644 --- a/sys/libkern/fnmatch.c +++ b/sys/libkern/fnmatch.c @@ -89,12 +89,12 @@ fnmatch(const char *pattern, const char *string, int flags) if (c == EOS) if (flags & FNM_PATHNAME) return ((flags & FNM_LEADING_DIR) || - index(string, '/') == NULL ? + strchr(string, '/') == NULL ? 0 : FNM_NOMATCH); else return (0); else if (c == '/' && flags & FNM_PATHNAME) { - if ((string = index(string, '/')) == NULL) + if ((string = strchr(string, '/')) == NULL) return (FNM_NOMATCH); break; } diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c index 20121baec750..d2e3a26400d3 100644 --- a/sys/netgraph/ng_ksocket.c +++ b/sys/netgraph/ng_ksocket.c @@ -223,7 +223,7 @@ ng_ksocket_sockaddr_parse(const struct ng_parse_type *type, /* Get socket address family followed by a slash */ while (isspace(s[*off])) (*off)++; - if ((t = index(s + *off, '/')) == NULL) + if ((t = strchr(s + *off, '/')) == NULL) return (EINVAL); if ((len = t - (s + *off)) > sizeof(fambuf) - 1) return (EINVAL); @@ -565,14 +565,14 @@ ng_ksocket_newhook(node_p node, hook_p hook, const char *name0) /* Extract family, type, and protocol from hook name */ snprintf(name, sizeof(name), "%s", name0); s1 = name; - if ((s2 = index(s1, '/')) == NULL) + if ((s2 = strchr(s1, '/')) == NULL) return (EINVAL); *s2++ = '\0'; family = ng_ksocket_parse(ng_ksocket_families, s1, 0); if (family == -1) return (EINVAL); s1 = s2; - if ((s2 = index(s1, '/')) == NULL) + if ((s2 = strchr(s1, '/')) == NULL) return (EINVAL); *s2++ = '\0'; type = ng_ksocket_parse(ng_ksocket_types, s1, 0); diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c index fe7168124442..8dc92e4e6ff5 100644 --- a/sys/security/mac_lomac/mac_lomac.c +++ b/sys/security/mac_lomac/mac_lomac.c @@ -762,10 +762,10 @@ lomac_parse(struct mac_lomac *ml, char *string) /* Do we have a range? */ single = string; - range = index(string, '('); + range = strchr(string, '('); if (range == single) single = NULL; - auxsingle = index(string, '['); + auxsingle = strchr(string, '['); if (auxsingle == single) single = NULL; if (range != NULL && auxsingle != NULL) @@ -776,13 +776,13 @@ lomac_parse(struct mac_lomac *ml, char *string) *range = '\0'; range++; rangelow = range; - rangehigh = index(rangelow, '-'); + rangehigh = strchr(rangelow, '-'); if (rangehigh == NULL) return (EINVAL); rangehigh++; if (*rangelow == '\0' || *rangehigh == '\0') return (EINVAL); - rangeend = index(rangehigh, ')'); + rangeend = strchr(rangehigh, ')'); if (rangeend == NULL) return (EINVAL); if (*(rangeend + 1) != '\0') @@ -798,7 +798,7 @@ lomac_parse(struct mac_lomac *ml, char *string) /* Nul terminate the end of the single string. */ *auxsingle = '\0'; auxsingle++; - auxsingleend = index(auxsingle, ']'); + auxsingleend = strchr(auxsingle, ']'); if (auxsingleend == NULL) return (EINVAL); if (*(auxsingleend + 1) != '\0')