Date: Tue, 19 Apr 2016 23:48:27 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298310 - in head/sys: compat/linux ddb fs/autofs fs/nfs geom/part kern net netinet netinet6 netipsec netnatm netsmb Message-ID: <201604192348.u3JNmRGs097156@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Tue Apr 19 23:48:27 2016 New Revision: 298310 URL: https://svnweb.freebsd.org/changeset/base/298310 Log: kernel: use our nitems() macro when it is available through param.h. No functional change, only trivial cases are done in this sweep, Discussed in: freebsd-current Modified: head/sys/compat/linux/linux_socket.c head/sys/ddb/db_variables.c head/sys/fs/autofs/autofs.c head/sys/fs/nfs/nfs_commonkrpc.c head/sys/geom/part/g_part_bsd.c head/sys/geom/part/g_part_ebr.c head/sys/geom/part/g_part_ldm.c head/sys/geom/part/g_part_mbr.c head/sys/kern/kern_dump.c head/sys/kern/kern_ffclock.c head/sys/kern/kern_jail.c head/sys/kern/kern_ktrace.c head/sys/kern/subr_hash.c head/sys/kern/subr_witness.c head/sys/kern/sysv_msg.c head/sys/kern/sysv_sem.c head/sys/kern/uipc_usrreq.c head/sys/net/rtsock.c head/sys/netinet/in_proto.c head/sys/netinet/tcp_syncache.c head/sys/netinet6/in6_proto.c head/sys/netipsec/key.c head/sys/netipsec/keysock.c head/sys/netnatm/natm_proto.c head/sys/netsmb/smb_smb.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/compat/linux/linux_socket.c Tue Apr 19 23:48:27 2016 (r298310) @@ -1703,7 +1703,7 @@ static const unsigned char lxs_args[] = LINUX_AL(4) /* sendmmsg */ }; -#define LINUX_AL_SIZE sizeof(lxs_args) / sizeof(lxs_args[0]) - 1 +#define LINUX_AL_SIZE (nitems(lxs_args) - 1) int linux_socketcall(struct thread *td, struct linux_socketcall_args *args) Modified: head/sys/ddb/db_variables.c ============================================================================== --- head/sys/ddb/db_variables.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/ddb/db_variables.c Tue Apr 19 23:48:27 2016 (r298310) @@ -54,7 +54,7 @@ static struct db_variable db_vars[] = { #endif }; static struct db_variable *db_evars = - db_vars + sizeof(db_vars)/sizeof(db_vars[0]); + db_vars + nitems(db_vars); static int db_find_variable(struct db_variable **varp) Modified: head/sys/fs/autofs/autofs.c ============================================================================== --- head/sys/fs/autofs/autofs.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/fs/autofs/autofs.c Tue Apr 19 23:48:27 2016 (r298310) @@ -354,7 +354,7 @@ autofs_set_sigmask(sigset_t *oldset) /* Remove the autofs set of signals from newset */ PROC_LOCK(curproc); mtx_lock(&curproc->p_sigacts->ps_mtx); - for (i = 0 ; i < sizeof(autofs_sig_set)/sizeof(int) ; i++) { + for (i = 0 ; i < nitems(autofs_sig_set); i++) { /* * But make sure we leave the ones already masked * by the process, i.e. remove the signal from the Modified: head/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- head/sys/fs/nfs/nfs_commonkrpc.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/fs/nfs/nfs_commonkrpc.c Tue Apr 19 23:48:27 2016 (r298310) @@ -1053,7 +1053,7 @@ nfs_sig_pending(sigset_t set) { int i; - for (i = 0 ; i < sizeof(newnfs_sig_set)/sizeof(int) ; i++) + for (i = 0 ; i < nitems(newnfs_sig_set); i++) if (SIGISMEMBER(set, newnfs_sig_set[i])) return (1); return (0); @@ -1078,7 +1078,7 @@ newnfs_set_sigmask(struct thread *td, si /* Remove the NFS set of signals from newset */ PROC_LOCK(p); mtx_lock(&p->p_sigacts->ps_mtx); - for (i = 0 ; i < sizeof(newnfs_sig_set)/sizeof(int) ; i++) { + for (i = 0 ; i < nitems(newnfs_sig_set); i++) { /* * But make sure we leave the ones already masked * by the process, ie. remove the signal from the Modified: head/sys/geom/part/g_part_bsd.c ============================================================================== --- head/sys/geom/part/g_part_bsd.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/geom/part/g_part_bsd.c Tue Apr 19 23:48:27 2016 (r298310) @@ -141,7 +141,7 @@ bsd_parse_type(const char *type, uint8_t return (0); } for (i = 0; - i < sizeof(bsd_alias_match) / sizeof(bsd_alias_match[0]); i++) { + i < nitems(bsd_alias_match); i++) { alias = g_part_alias_name(bsd_alias_match[i].alias); if (strcasecmp(type, alias) == 0) { *fstype = bsd_alias_match[i].type; Modified: head/sys/geom/part/g_part_ebr.c ============================================================================== --- head/sys/geom/part/g_part_ebr.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/geom/part/g_part_ebr.c Tue Apr 19 23:48:27 2016 (r298310) @@ -189,7 +189,7 @@ ebr_parse_type(const char *type, u_char return (0); } for (i = 0; - i < sizeof(ebr_alias_match) / sizeof(ebr_alias_match[0]); i++) { + i < nitems(ebr_alias_match); i++) { alias = g_part_alias_name(ebr_alias_match[i].alias); if (strcasecmp(type, alias) == 0) { *dp_typ = ebr_alias_match[i].typ; @@ -604,7 +604,7 @@ g_part_ebr_type(struct g_part_table *bas entry = (struct g_part_ebr_entry *)baseentry; for (i = 0; - i < sizeof(ebr_alias_match) / sizeof(ebr_alias_match[0]); i++) { + i < nitems(ebr_alias_match); i++) { if (ebr_alias_match[i].typ == entry->ent.dp_typ) return (g_part_alias_name(ebr_alias_match[i].alias)); } Modified: head/sys/geom/part/g_part_ldm.c ============================================================================== --- head/sys/geom/part/g_part_ldm.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/geom/part/g_part_ldm.c Tue Apr 19 23:48:27 2016 (r298310) @@ -454,7 +454,7 @@ ldm_privhdr_check(struct ldm_db *db, str } else last = pp->mediasize / pp->sectorsize - 1; for (found = 0, i = is_gpt; - i < sizeof(ldm_ph_off) / sizeof(ldm_ph_off[0]); i++) { + i < nitems(ldm_ph_off); i++) { offset = ldm_ph_off[i]; /* * In the GPT case consumer is attached to the LDM metadata @@ -1469,7 +1469,7 @@ g_part_ldm_type(struct g_part_table *bas entry = (struct g_part_ldm_entry *)baseentry; for (i = 0; - i < sizeof(ldm_alias_match) / sizeof(ldm_alias_match[0]); i++) { + i < nitems(ldm_alias_match); i++) { if (ldm_alias_match[i].typ == entry->type) return (g_part_alias_name(ldm_alias_match[i].alias)); } Modified: head/sys/geom/part/g_part_mbr.c ============================================================================== --- head/sys/geom/part/g_part_mbr.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/geom/part/g_part_mbr.c Tue Apr 19 23:48:27 2016 (r298310) @@ -159,7 +159,7 @@ mbr_parse_type(const char *type, u_char return (0); } for (i = 0; - i < sizeof(mbr_alias_match) / sizeof(mbr_alias_match[0]); i++) { + i < nitems(mbr_alias_match); i++) { alias = g_part_alias_name(mbr_alias_match[i].alias); if (strcasecmp(type, alias) == 0) { *dp_typ = mbr_alias_match[i].typ; @@ -561,7 +561,7 @@ g_part_mbr_type(struct g_part_table *bas entry = (struct g_part_mbr_entry *)baseentry; for (i = 0; - i < sizeof(mbr_alias_match) / sizeof(mbr_alias_match[0]); i++) { + i < nitems(mbr_alias_match); i++) { if (mbr_alias_match[i].typ == entry->ent.dp_typ) return (g_part_alias_name(mbr_alias_match[i].alias)); } Modified: head/sys/kern/kern_dump.c ============================================================================== --- head/sys/kern/kern_dump.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/kern_dump.c Tue Apr 19 23:48:27 2016 (r298310) @@ -71,7 +71,7 @@ dumpsys_gen_pa_init(void) int n, idx; bzero(dump_map, sizeof(dump_map)); - for (n = 0; n < sizeof(dump_map) / sizeof(dump_map[0]); n++) { + for (n = 0; n < nitems(dump_map); n++) { idx = n * 2; if (dump_avail[idx] == 0 && dump_avail[idx + 1] == 0) break; Modified: head/sys/kern/kern_ffclock.c ============================================================================== --- head/sys/kern/kern_ffclock.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/kern_ffclock.c Tue Apr 19 23:48:27 2016 (r298310) @@ -160,7 +160,7 @@ SYSCTL_NODE(_kern_sysclock, OID_AUTO, ff static char *sysclocks[] = {"feedback", "feed-forward"}; #define MAX_SYSCLOCK_NAME_LEN 16 -#define NUM_SYSCLOCKS (sizeof(sysclocks) / sizeof(*sysclocks)) +#define NUM_SYSCLOCKS nitems(sysclocks) static int ffclock_version = 2; SYSCTL_INT(_kern_sysclock_ffclock, OID_AUTO, version, CTLFLAG_RD, Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/kern_jail.c Tue Apr 19 23:48:27 2016 (r298310) @@ -357,8 +357,7 @@ sys_jail(struct thread *td, struct jail_ int kern_jail(struct thread *td, struct jail *j) { - struct iovec optiov[2 * (4 - + sizeof(pr_allow_names) / sizeof(pr_allow_names[0]) + struct iovec optiov[2 * (4 + nitems(pr_allow_names) #ifdef INET + 1 #endif @@ -389,8 +388,7 @@ kern_jail(struct thread *td, struct jail /* Set permissions for top-level jails from sysctls. */ if (!jailed(td->td_ucred)) { - for (fi = 0; fi < sizeof(pr_allow_names) / - sizeof(pr_allow_names[0]); fi++) { + for (fi = 0; fi < nitems(pr_allow_names); fi++) { optiov[opt.uio_iovcnt].iov_base = (jail_default_allow & (1 << fi)) ? pr_allow_names[fi] : pr_allow_nonames[fi]; @@ -503,8 +501,8 @@ kern_jail(struct thread *td, struct jail } opt.uio_iovcnt++; #endif - KASSERT(opt.uio_iovcnt <= sizeof(optiov) / sizeof(optiov[0]), - ("kern_jail: too many iovecs (%d)", opt.uio_iovcnt)); + KASSERT(opt.uio_iovcnt <= nitems(optiov), + ("kern_jail: too many iovecs (%d)", opt.uio_iovcnt)); error = kern_jail_set(td, &opt, JAIL_CREATE | JAIL_ATTACH); free(u_path, M_TEMP); return (error); @@ -651,16 +649,14 @@ kern_jail_set(struct thread *td, struct gotrsnum = 1; pr_flags = ch_flags = 0; - for (fi = 0; fi < sizeof(pr_flag_names) / sizeof(pr_flag_names[0]); - fi++) { + for (fi = 0; fi < nitems(pr_flag_names); fi++) { if (pr_flag_names[fi] == NULL) continue; vfs_flagopt(opts, pr_flag_names[fi], &pr_flags, 1 << fi); vfs_flagopt(opts, pr_flag_nonames[fi], &ch_flags, 1 << fi); } ch_flags |= pr_flags; - for (fi = 0; fi < sizeof(pr_flag_jailsys) / sizeof(pr_flag_jailsys[0]); - fi++) { + for (fi = 0; fi < nitems(pr_flag_jailsys); fi++) { error = vfs_copyopt(opts, pr_flag_jailsys[fi].name, &jsys, sizeof(jsys)); if (error == ENOENT) @@ -716,8 +712,7 @@ kern_jail_set(struct thread *td, struct #endif pr_allow = ch_allow = 0; - for (fi = 0; fi < sizeof(pr_allow_names) / sizeof(pr_allow_names[0]); - fi++) { + for (fi = 0; fi < nitems(pr_allow_names); fi++) { vfs_flagopt(opts, pr_allow_names[fi], &pr_allow, 1 << fi); vfs_flagopt(opts, pr_allow_nonames[fi], &ch_allow, 1 << fi); } @@ -2136,8 +2131,7 @@ kern_jail_get(struct thread *td, struct sizeof(pr->pr_devfs_rsnum)); if (error != 0 && error != ENOENT) goto done_deref; - for (fi = 0; fi < sizeof(pr_flag_names) / sizeof(pr_flag_names[0]); - fi++) { + for (fi = 0; fi < nitems(pr_flag_names); fi++) { if (pr_flag_names[fi] == NULL) continue; i = (pr->pr_flags & (1 << fi)) ? 1 : 0; @@ -2149,8 +2143,7 @@ kern_jail_get(struct thread *td, struct if (error != 0 && error != ENOENT) goto done_deref; } - for (fi = 0; fi < sizeof(pr_flag_jailsys) / sizeof(pr_flag_jailsys[0]); - fi++) { + for (fi = 0; fi < nitems(pr_flag_jailsys); fi++) { i = pr->pr_flags & (pr_flag_jailsys[fi].disable | pr_flag_jailsys[fi].new); i = pr_flag_jailsys[fi].disable && @@ -2162,8 +2155,7 @@ kern_jail_get(struct thread *td, struct if (error != 0 && error != ENOENT) goto done_deref; } - for (fi = 0; fi < sizeof(pr_allow_names) / sizeof(pr_allow_names[0]); - fi++) { + for (fi = 0; fi < nitems(pr_allow_names); fi++) { if (pr_allow_names[fi] == NULL) continue; i = (pr->pr_allow & (1 << fi)) ? 1 : 0; @@ -4694,12 +4686,10 @@ db_show_prison(struct prison *pr) db_printf(" child = %p\n", LIST_FIRST(&pr->pr_children)); db_printf(" sibling = %p\n", LIST_NEXT(pr, pr_sibling)); db_printf(" flags = 0x%x", pr->pr_flags); - for (fi = 0; fi < sizeof(pr_flag_names) / sizeof(pr_flag_names[0]); - fi++) + for (fi = 0; fi < nitems(pr_flag_names); fi++) if (pr_flag_names[fi] != NULL && (pr->pr_flags & (1 << fi))) db_printf(" %s", pr_flag_names[fi]); - for (fi = 0; fi < sizeof(pr_flag_jailsys) / sizeof(pr_flag_jailsys[0]); - fi++) { + for (fi = 0; fi < nitems(pr_flag_jailsys); fi++) { jsf = pr->pr_flags & (pr_flag_jailsys[fi].disable | pr_flag_jailsys[fi].new); db_printf(" %-16s= %s\n", pr_flag_jailsys[fi].name, @@ -4709,8 +4699,7 @@ db_show_prison(struct prison *pr) : "inherit"); } db_printf(" allow = 0x%x", pr->pr_allow); - for (fi = 0; fi < sizeof(pr_allow_names) / sizeof(pr_allow_names[0]); - fi++) + for (fi = 0; fi < nitems(pr_allow_names); fi++) if (pr_allow_names[fi] != NULL && (pr->pr_allow & (1 << fi))) db_printf(" %s", pr_allow_names[fi]); db_printf("\n"); Modified: head/sys/kern/kern_ktrace.c ============================================================================== --- head/sys/kern/kern_ktrace.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/kern_ktrace.c Tue Apr 19 23:48:27 2016 (r298310) @@ -1163,8 +1163,7 @@ ktr_writerequest(struct thread *td, stru mtx_unlock(&ktrace_mtx); kth = &req->ktr_header; - KASSERT(((u_short)kth->ktr_type & ~KTR_DROP) < - sizeof(data_lengths) / sizeof(data_lengths[0]), + KASSERT(((u_short)kth->ktr_type & ~KTR_DROP) < nitems(data_lengths), ("data_lengths array overflow")); datalen = data_lengths[(u_short)kth->ktr_type & ~KTR_DROP]; buflen = kth->ktr_len; Modified: head/sys/kern/subr_hash.c ============================================================================== --- head/sys/kern/subr_hash.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/subr_hash.c Tue Apr 19 23:48:27 2016 (r298310) @@ -101,7 +101,7 @@ hashdestroy(void *vhashtbl, struct mallo static const int primes[] = { 1, 13, 31, 61, 127, 251, 509, 761, 1021, 1531, 2039, 2557, 3067, 3583, 4093, 4603, 5119, 5623, 6143, 6653, 7159, 7673, 8191, 12281, 16381, 24571, 32749 }; -#define NPRIMES (sizeof(primes) / sizeof(primes[0])) +#define NPRIMES nitems(primes) /* * General routine to allocate a prime number sized hash table. Modified: head/sys/kern/subr_witness.c ============================================================================== --- head/sys/kern/subr_witness.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/subr_witness.c Tue Apr 19 23:48:27 2016 (r298310) @@ -709,8 +709,7 @@ static struct witness_order_list_entry o */ static struct witness_blessed blessed_list[] = { }; -static int blessed_count = - sizeof(blessed_list) / sizeof(struct witness_blessed); +static int blessed_count = nitems(blessed_list); #endif /* Modified: head/sys/kern/sysv_msg.c ============================================================================== --- head/sys/kern/sysv_msg.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/sysv_msg.c Tue Apr 19 23:48:27 2016 (r298310) @@ -1519,7 +1519,7 @@ sys_msgsys(td, uap) if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) return (ENOSYS); if (uap->which < 0 || - uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0])) + uap->which >= nitems(msgcalls)) return (EINVAL); error = (*msgcalls[uap->which])(td, &uap->a2); return (error); Modified: head/sys/kern/sysv_sem.c ============================================================================== --- head/sys/kern/sysv_sem.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/sysv_sem.c Tue Apr 19 23:48:27 2016 (r298310) @@ -1401,7 +1401,7 @@ sys_semsys(td, uap) if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) return (ENOSYS); if (uap->which < 0 || - uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) + uap->which >= nitems(semcalls)) return (EINVAL); error = (*semcalls[uap->which])(td, &uap->a2); return (error); Modified: head/sys/kern/uipc_usrreq.c ============================================================================== --- head/sys/kern/uipc_usrreq.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/kern/uipc_usrreq.c Tue Apr 19 23:48:27 2016 (r298310) @@ -337,7 +337,7 @@ static struct domain localdomain = { .dom_externalize = unp_externalize, .dom_dispose = unp_dispose_so, .dom_protosw = localsw, - .dom_protoswNPROTOSW = &localsw[sizeof(localsw)/sizeof(localsw[0])] + .dom_protoswNPROTOSW = &localsw[nitems(localsw)] }; DOMAIN_SET(local); Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/net/rtsock.c Tue Apr 19 23:48:27 2016 (r298310) @@ -1919,7 +1919,7 @@ static struct domain routedomain = { .dom_family = PF_ROUTE, .dom_name = "route", .dom_protosw = routesw, - .dom_protoswNPROTOSW = &routesw[sizeof(routesw)/sizeof(routesw[0])] + .dom_protoswNPROTOSW = &routesw[nitems(routesw)] }; VNET_DOMAIN_SET(route); Modified: head/sys/netinet/in_proto.c ============================================================================== --- head/sys/netinet/in_proto.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/netinet/in_proto.c Tue Apr 19 23:48:27 2016 (r298310) @@ -357,7 +357,7 @@ struct domain inetdomain = { .dom_family = AF_INET, .dom_name = "internet", .dom_protosw = inetsw, - .dom_protoswNPROTOSW = &inetsw[sizeof(inetsw)/sizeof(inetsw[0])], + .dom_protoswNPROTOSW = &inetsw[nitems(inetsw)], #ifdef RADIX_MPATH .dom_rtattach = rn4_mpath_inithead, #else Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/netinet/tcp_syncache.c Tue Apr 19 23:48:27 2016 (r298310) @@ -1896,7 +1896,7 @@ syncookie_generate(struct syncache_head /* Map our computed MSS into the 3-bit index. */ mss = min(tcp_mssopt(&sc->sc_inc), max(sc->sc_peer_mss, V_tcp_minmss)); - for (i = sizeof(tcp_sc_msstab) / sizeof(*tcp_sc_msstab) - 1; + for (i = nitems(tcp_sc_msstab) - 1; tcp_sc_msstab[i] > mss && i > 0; i--) ; @@ -1908,7 +1908,7 @@ syncookie_generate(struct syncache_head */ if (sc->sc_flags & SCF_WINSCALE) { wscale = sc->sc_requested_s_scale; - for (i = sizeof(tcp_sc_wstab) / sizeof(*tcp_sc_wstab) - 1; + for (i = nitems(tcp_sc_wstab) - 1; tcp_sc_wstab[i] > wscale && i > 0; i--) ; Modified: head/sys/netinet6/in6_proto.c ============================================================================== --- head/sys/netinet6/in6_proto.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/netinet6/in6_proto.c Tue Apr 19 23:48:27 2016 (r298310) @@ -382,7 +382,7 @@ struct domain inet6domain = { .dom_name = "internet6", .dom_protosw = (struct protosw *)inet6sw, .dom_protoswNPROTOSW = (struct protosw *) - &inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])], + &inet6sw[nitems(inet6sw)], #ifdef RADIX_MPATH .dom_rtattach = rn6_mpath_inithead, #else Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/netipsec/key.c Tue Apr 19 23:48:27 2016 (r298310) @@ -3365,7 +3365,7 @@ key_setdumpsa(struct secasvar *sav, u_in goto fail; result = m; - for (i = sizeof(dumporder)/sizeof(dumporder[0]) - 1; i >= 0; i--) { + for (i = nitems(dumporder) - 1; i >= 0; i--) { m = NULL; switch (dumporder[i]) { case SADB_EXT_SA: @@ -7410,7 +7410,7 @@ key_parse(struct mbuf *m, struct socket */ } - if (msg->sadb_msg_type >= sizeof(key_typesw)/sizeof(key_typesw[0]) || + if (msg->sadb_msg_type >= nitems(key_typesw) || key_typesw[msg->sadb_msg_type] == NULL) { PFKEYSTAT_INC(out_invmsgtype); error = EINVAL; @@ -7562,8 +7562,8 @@ key_validate_ext(const struct sadb_ext * return EINVAL; /* if it does not match minimum/maximum length, bail */ - if (ext->sadb_ext_type >= sizeof(minsize) / sizeof(minsize[0]) || - ext->sadb_ext_type >= sizeof(maxsize) / sizeof(maxsize[0])) + if (ext->sadb_ext_type >= nitems(minsize) || + ext->sadb_ext_type >= nitems(maxsize)) return EINVAL; if (!minsize[ext->sadb_ext_type] || len < minsize[ext->sadb_ext_type]) return EINVAL; Modified: head/sys/netipsec/keysock.c ============================================================================== --- head/sys/netipsec/keysock.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/netipsec/keysock.c Tue Apr 19 23:48:27 2016 (r298310) @@ -564,7 +564,7 @@ struct domain keydomain = { .dom_destroy = key_destroy, #endif .dom_protosw = keysw, - .dom_protoswNPROTOSW = &keysw[sizeof(keysw)/sizeof(keysw[0])] + .dom_protoswNPROTOSW = &keysw[nitems(keysw)] }; VNET_DOMAIN_SET(key); Modified: head/sys/netnatm/natm_proto.c ============================================================================== --- head/sys/netnatm/natm_proto.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/netnatm/natm_proto.c Tue Apr 19 23:48:27 2016 (r298310) @@ -87,7 +87,7 @@ static struct domain natmdomain = { .dom_name = "natm", .dom_init = natm_init, .dom_protosw = natmsw, - .dom_protoswNPROTOSW = &natmsw[sizeof(natmsw)/sizeof(natmsw[0])], + .dom_protoswNPROTOSW = &natmsw[nitems(natmsw)], }; static struct netisr_handler natm_nh = { Modified: head/sys/netsmb/smb_smb.c ============================================================================== --- head/sys/netsmb/smb_smb.c Tue Apr 19 23:44:33 2016 (r298309) +++ head/sys/netsmb/smb_smb.c Tue Apr 19 23:48:27 2016 (r298310) @@ -68,7 +68,7 @@ static struct smb_dialect smb_dialects[] {-1, NULL} }; -#define SMB_DIALECT_MAX (sizeof(smb_dialects) / sizeof(struct smb_dialect) - 2) +#define SMB_DIALECT_MAX (nitems(smb_dialects) - 2) static u_int32_t smb_vc_maxread(struct smb_vc *vcp)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604192348.u3JNmRGs097156>