git: afd0c206a6ce - main - ctladm: Use nitems() in a few more places

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 02 May 2024 16:55:37 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=afd0c206a6ce9a182c1a26a4d8dbb66a8335f519

commit afd0c206a6ce9a182c1a26a4d8dbb66a8335f519
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-05-02 16:55:15 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-05-02 16:55:15 +0000

    ctladm: Use nitems() in a few more places
    
    Sponsored by:   Chelsio Communications
    
    Differential Revision:  https://reviews.freebsd.org/D45017
---
 usr.sbin/ctladm/ctladm.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index 81b8d3196357..15cbf2d6cd77 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -2806,8 +2806,7 @@ cctl_islist_start_element(void *user_data, const char *name, const char **attr)
 	islist = (struct cctl_islist_data *)user_data;
 	cur_conn = islist->cur_conn;
 	islist->level++;
-	if ((u_int)islist->level >= (sizeof(islist->cur_sb) /
-	    sizeof(islist->cur_sb[0])))
+	if ((u_int)islist->level >= nitems(islist->cur_sb))
 		errx(1, "%s: too many nesting levels, %zd max", __func__,
 		     nitems(islist->cur_sb));
 
@@ -3237,8 +3236,7 @@ cctl_start_element(void *user_data, const char *name, const char **attr)
 	devlist = (struct cctl_devlist_data *)user_data;
 	cur_lun = devlist->cur_lun;
 	devlist->level++;
-	if ((u_int)devlist->level >= (sizeof(devlist->cur_sb) /
-	    sizeof(devlist->cur_sb[0])))
+	if ((u_int)devlist->level >= nitems(devlist->cur_sb))
 		errx(1, "%s: too many nesting levels, %zd max", __func__,
 		     nitems(devlist->cur_sb));
 
@@ -3501,8 +3499,7 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr)
 	portlist = (struct cctl_portlist_data *)user_data;
 	cur_port = portlist->cur_port;
 	portlist->level++;
-	if ((u_int)portlist->level >= (sizeof(portlist->cur_sb) /
-	    sizeof(portlist->cur_sb[0])))
+	if ((u_int)portlist->level >= nitems(portlist->cur_sb))
 		errx(1, "%s: too many nesting levels, %zd max", __func__,
 		     nitems(portlist->cur_sb));