summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authoraraujo <araujo@FreeBSD.org>2017-04-17 18:55:54 +0000
committeraraujo <araujo@FreeBSD.org>2017-04-17 18:55:54 +0000
commita52fbfbaa6cb040819aaa956af20324f4cf1b1f9 (patch)
tree647b1c8fb6ffc61d7646056b90483cfd245a7867 /usr.sbin
parent1e35d29d6289b2c15cca0f7e951e77e144f0b08e (diff)
downloadFreeBSD-src-a52fbfbaa6cb040819aaa956af20324f4cf1b1f9.zip
FreeBSD-src-a52fbfbaa6cb040819aaa956af20324f4cf1b1f9.tar.gz
MFC r314987-r314989, r314993-r314994, r315046-r315049, r315102
r314987: Use nitems() from sys/param.h. Reviewed by: asomers MFC after: 3 weeks. Differential Revision: https://reviews.freebsd.org/D9944 r314988: Use nitems() from sys/param.h. Reviewed by: ume MFC after: 3 weeks. Differential Revision: https://reviews.freebsd.org/D9938 r314989: Use nitems() from sys/param.h and also remove the cast. Reviewed by: markj MFC after: 3 weeks. Differential Revision: https://reviews.freebsd.org/D9937 r314993: Use nitems() from sys/param.h. Reviewed by: ngie MFC after: 3 weeks. Differential Revision: https://reviews.freebsd.org/D9936 r314994: Use nitems() from sys/param.h. Reviewed by: ngie MFC after: 3 weeks. Differential Revision: https://reviews.freebsd.org/D9940 r315046: Use nitems() from sys/param.h Reviewed by: jhb MFC after: 3 weeks. Differential Revision: https://reviews.freebsd.org/D9941 r315047: Use nitems() from sys/param.h. Reviewed by: np MFC after: 3 weeks. Differential Revision: https://reviews.freebsd.org/D9945 r315048: Use nitems() from sys/param.h. MFC after: 3 weeks. r315049: Bring back the cast removed in my previous commit to allow us build vmstat with WARNS 2. This cast was first introduced at r87690. Reported by: bde, pfg and ngie MFC after: 3 weeks. r315102: Use nitems() from sys/param.h. Reviewed by: ngie Differential Revision: https://reviews.freebsd.org/D9943
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/acpi/acpidump/acpi.c7
-rw-r--r--usr.sbin/boot0cfg/boot0cfg.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c2
-rw-r--r--usr.sbin/camdd/camdd.c3
-rw-r--r--usr.sbin/ctld/kernel.c4
-rw-r--r--usr.sbin/iscsid/iscsid.c4
6 files changed, 10 insertions, 12 deletions
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index 076a8ff..f9d19f4 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -394,7 +394,7 @@ acpi_print_madt(ACPI_SUBTABLE_HEADER *mp)
ACPI_MADT_LOCAL_X2APIC *x2apic;
ACPI_MADT_LOCAL_X2APIC_NMI *x2apic_nmi;
- if (mp->Type < sizeof(apic_types) / sizeof(apic_types[0]))
+ if (mp->Type < nitems(apic_types))
printf("\tType=%s\n", apic_types[mp->Type]);
else
printf("\tType=%d (unknown)\n", mp->Type);
@@ -444,8 +444,7 @@ acpi_print_madt(ACPI_SUBTABLE_HEADER *mp)
break;
case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
isrc = (ACPI_MADT_INTERRUPT_SOURCE *)mp;
- if (isrc->Type < sizeof(platform_int_types) /
- sizeof(platform_int_types[0]))
+ if (isrc->Type < nitems(platform_int_types))
printf("\tType=%s\n", platform_int_types[isrc->Type]);
else
printf("\tType=%d (unknown)\n", isrc->Type);
@@ -1020,7 +1019,7 @@ acpi_print_srat(ACPI_SUBTABLE_HEADER *srat)
ACPI_SRAT_CPU_AFFINITY *cpu;
ACPI_SRAT_X2APIC_CPU_AFFINITY *x2apic;
- if (srat->Type < sizeof(srat_types) / sizeof(srat_types[0]))
+ if (srat->Type < nitems(srat_types))
printf("\tType=%s\n", srat_types[srat->Type]);
else
printf("\tType=%d (unknown)\n", srat->Type);
diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c
index c2cb91d..9670af9 100644
--- a/usr.sbin/boot0cfg/boot0cfg.c
+++ b/usr.sbin/boot0cfg/boot0cfg.c
@@ -88,7 +88,7 @@ static const struct {
{"update", 1},
{"setdrv", 0}
};
-static const int nopt = sizeof(opttbl) / sizeof(opttbl[0]);
+static const int nopt = nitems(opttbl);
static const char fmt0[] = "# flag start chs type"
" end chs offset size\n";
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
index 9470677..b88541f 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
@@ -143,7 +143,7 @@ static const struct {
{ "hpfs", &OIDX_hrFSHPFS_c },
{ "smbfs", &OIDX_hrFSOther_c },
};
-#define N_FS_TYPE_MAP (sizeof(fs_type_map) / sizeof(fs_type_map[0]))
+#define N_FS_TYPE_MAP nitems(fs_type_map)
/**
* Create an entry into the FS table and an entry in the map (if needed).
diff --git a/usr.sbin/camdd/camdd.c b/usr.sbin/camdd/camdd.c
index 05225f6..9da57b0 100644
--- a/usr.sbin/camdd/camdd.c
+++ b/usr.sbin/camdd/camdd.c
@@ -1004,8 +1004,7 @@ camdd_probe_tape(int fd, char *filename, uint64_t *max_iosize,
goto bailout;
}
- for (i = 0; i < sizeof(req_status_items) /
- sizeof(req_status_items[0]); i++) {
+ for (i = 0; i < nitems(req_status_items); i++) {
char *name;
name = __DECONST(char *, req_status_items[i].name);
diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c
index 057ea34..e1376c7 100644
--- a/usr.sbin/ctld/kernel.c
+++ b/usr.sbin/ctld/kernel.c
@@ -1259,8 +1259,8 @@ kernel_capsicate(void)
if (error != 0 && errno != ENOSYS)
log_err(1, "cap_rights_limit");
- error = cap_ioctls_limit(ctl_fd, cmds,
- sizeof(cmds) / sizeof(cmds[0]));
+ error = cap_ioctls_limit(ctl_fd, cmds, nitems(cmds));
+
if (error != 0 && errno != ENOSYS)
log_err(1, "cap_ioctls_limit");
diff --git a/usr.sbin/iscsid/iscsid.c b/usr.sbin/iscsid/iscsid.c
index 5be7a44..1671dda 100644
--- a/usr.sbin/iscsid/iscsid.c
+++ b/usr.sbin/iscsid/iscsid.c
@@ -326,8 +326,8 @@ capsicate(struct connection *conn)
if (error != 0 && errno != ENOSYS)
log_err(1, "cap_rights_limit");
- error = cap_ioctls_limit(conn->conn_iscsi_fd, cmds,
- sizeof(cmds) / sizeof(cmds[0]));
+ error = cap_ioctls_limit(conn->conn_iscsi_fd, cmds, nitems(cmds));
+
if (error != 0 && errno != ENOSYS)
log_err(1, "cap_ioctls_limit");
OpenPOWER on IntegriCloud