git: b2a3826e9d59 - stable/14 - ctld: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])

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

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

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

    ctld: 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 8f65dcd6276bf139a2fe87c1bbeffcc1fed015e4)
---
 usr.sbin/ctld/kernel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c
index cbb8e2c25f5d..ec46a9b765a8 100644
--- a/usr.sbin/ctld/kernel.c
+++ b/usr.sbin/ctld/kernel.c
@@ -169,7 +169,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])))
 		log_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)
@@ -291,7 +291,7 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr)
 	if ((u_int)devlist->level >= (sizeof(devlist->cur_sb) /
 	    sizeof(devlist->cur_sb[0])))
 		log_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)