Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Aug 2024 18:07:20 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 52bc3fae713d - stable/14 - ctladm: Use nitems() in a few more places
Message-ID:  <202408271807.47RI7Kbn094323@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by jhb:

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

commit 52bc3fae713ddbec6310d842de1d8bf2cecec9af
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-05-02 16:55:15 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-08-27 16:35:34 +0000

    ctladm: Use nitems() in a few more places
    
    Sponsored by:   Chelsio Communications
    
    Differential Revision:  https://reviews.freebsd.org/D45017
    
    (cherry picked from commit afd0c206a6ce9a182c1a26a4d8dbb66a8335f519)
---
 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 f06e70322708..4426274fdd44 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -2807,8 +2807,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));
 
@@ -3238,8 +3237,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));
 
@@ -3502,8 +3500,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));
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202408271807.47RI7Kbn094323>