git: 9f01ac2f7d6b - stable/14 - ctladm: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 27 Aug 2024 18:07:19 UTC
The branch stable/14 has been updated by jhb:

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

commit 9f01ac2f7d6b7dbe2301183b25181eb8b4284cf4
Author:     Elyes Haouas <ehaouas@noos.fr>
AuthorDate: 2023-11-07 17:11:10 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-08-27 16:35:34 +0000

    ctladm: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
    
    Pull Request: https://github.com/freebsd/freebsd-src/pull/888
    Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
    (cherry picked from commit 2f8ea2f605acbeadb3c2fe9d336fcf558f2d4fa6)
---
 usr.sbin/ctladm/ctladm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index 228af7bae8c6..f06e70322708 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -2810,7 +2810,7 @@ cctl_islist_start_element(void *user_data, const char *name, const char **attr)
 	if ((u_int)islist->level >= (sizeof(islist->cur_sb) /
 	    sizeof(islist->cur_sb[0])))
 		errx(1, "%s: too many nesting levels, %zd max", __func__,
-		     sizeof(islist->cur_sb) / sizeof(islist->cur_sb[0]));
+		     nitems(islist->cur_sb));
 
 	islist->cur_sb[islist->level] = sbuf_new_auto();
 	if (islist->cur_sb[islist->level] == NULL)
@@ -3241,7 +3241,7 @@ cctl_start_element(void *user_data, const char *name, const char **attr)
 	if ((u_int)devlist->level >= (sizeof(devlist->cur_sb) /
 	    sizeof(devlist->cur_sb[0])))
 		errx(1, "%s: too many nesting levels, %zd max", __func__,
-		     sizeof(devlist->cur_sb) / sizeof(devlist->cur_sb[0]));
+		     nitems(devlist->cur_sb));
 
 	devlist->cur_sb[devlist->level] = sbuf_new_auto();
 	if (devlist->cur_sb[devlist->level] == NULL)
@@ -3505,7 +3505,7 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr)
 	if ((u_int)portlist->level >= (sizeof(portlist->cur_sb) /
 	    sizeof(portlist->cur_sb[0])))
 		errx(1, "%s: too many nesting levels, %zd max", __func__,
-		     sizeof(portlist->cur_sb) / sizeof(portlist->cur_sb[0]));
+		     nitems(portlist->cur_sb));
 
 	portlist->cur_sb[portlist->level] = sbuf_new_auto();
 	if (portlist->cur_sb[portlist->level] == NULL)