diff options
author | pfg <pfg@FreeBSD.org> | 2016-04-21 15:38:28 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-04-21 15:38:28 +0000 |
commit | fc65edc1cd05de15ef17e14dc54c2bf6c41ccab8 (patch) | |
tree | 45622d9ce5a6c394316a37f672cfd0a033c48374 /sys/security | |
parent | fdf39652a42767663d4a74a1a367d193185c51e9 (diff) | |
download | FreeBSD-src-fc65edc1cd05de15ef17e14dc54c2bf6c41ccab8.zip FreeBSD-src-fc65edc1cd05de15ef17e14dc54c2bf6c41ccab8.tar.gz |
Remove slightly used const values that can be replaced with nitems().
Suggested by: jhb
Diffstat (limited to 'sys/security')
-rw-r--r-- | sys/security/audit/audit_bsm_klib.c | 6 | ||||
-rw-r--r-- | sys/security/audit/bsm_errno.c | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/sys/security/audit/audit_bsm_klib.c b/sys/security/audit/audit_bsm_klib.c index b687a15..f44fac9 100644 --- a/sys/security/audit/audit_bsm_klib.c +++ b/sys/security/audit/audit_bsm_klib.c @@ -95,7 +95,6 @@ static const struct aue_open_event aue_open[] = { { (O_WRONLY | O_CREAT | O_TRUNC), AUE_OPEN_WTC }, { (O_WRONLY | O_TRUNC), AUE_OPEN_WT }, }; -static const int aue_open_count = sizeof(aue_open) / sizeof(aue_open[0]); static const struct aue_open_event aue_openat[] = { { O_RDONLY, AUE_OPENAT_R }, @@ -111,7 +110,6 @@ static const struct aue_open_event aue_openat[] = { { (O_WRONLY | O_CREAT | O_TRUNC), AUE_OPENAT_WTC }, { (O_WRONLY | O_TRUNC), AUE_OPENAT_WT }, }; -static const int aue_openat_count = sizeof(aue_openat) / sizeof(aue_openat[0]); /* * Look up the class for an audit event in the class mapping table. @@ -296,7 +294,7 @@ audit_flags_and_error_to_openevent(int oflags, int error) * Need to check only those flags we care about. */ oflags = oflags & (O_RDONLY | O_CREAT | O_TRUNC | O_RDWR | O_WRONLY); - for (i = 0; i < aue_open_count; i++) { + for (i = 0; i < nitems(aue_open); i++) { if (aue_open[i].aoe_flags == oflags) return (aue_open[i].aoe_event); } @@ -312,7 +310,7 @@ audit_flags_and_error_to_openatevent(int oflags, int error) * Need to check only those flags we care about. */ oflags = oflags & (O_RDONLY | O_CREAT | O_TRUNC | O_RDWR | O_WRONLY); - for (i = 0; i < aue_openat_count; i++) { + for (i = 0; i < nitems(aue_openat); i++) { if (aue_openat[i].aoe_flags == oflags) return (aue_openat[i].aoe_event); } diff --git a/sys/security/audit/bsm_errno.c b/sys/security/audit/bsm_errno.c index bb746b5..9506025 100644 --- a/sys/security/audit/bsm_errno.c +++ b/sys/security/audit/bsm_errno.c @@ -699,14 +699,13 @@ static const struct bsm_errno bsm_errnos[] = { #endif ES("Not permitted in capability mode") }, }; -static const int bsm_errnos_count = sizeof(bsm_errnos) / sizeof(bsm_errnos[0]); static const struct bsm_errno * bsm_lookup_errno_local(int local_errno) { int i; - for (i = 0; i < bsm_errnos_count; i++) { + for (i = 0; i < nitems(bsm_errnos); i++) { if (bsm_errnos[i].be_local_errno == local_errno) return (&bsm_errnos[i]); } @@ -733,7 +732,7 @@ bsm_lookup_errno_bsm(u_char bsm_errno) { int i; - for (i = 0; i < bsm_errnos_count; i++) { + for (i = 0; i < nitems(bsm_errnos); i++) { if (bsm_errnos[i].be_bsm_errno == bsm_errno) return (&bsm_errnos[i]); } |