]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/, src/, tests/: Use the standard countof() instead of our NITEMS()
authorAlejandro Colomar <alx@kernel.org>
Wed, 21 May 2025 11:33:37 +0000 (13:33 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 3 Jun 2025 14:34:55 +0000 (09:34 -0500)
commitba3456c9fd7decc16c6aaacd4c6651cc58438149
treec894ba6308af3930d4a35a5bac4b222faab2b76b
parenta5fc731dea62b542c68516872efa0fff818f5a1c
lib/, src/, tests/: Use the standard countof() instead of our NITEMS()

countof() is the name blessed by the C Committee for ISO C2y.
Use it if available, and define it if not.

countof() will be provided by GCC 16 and Clang 21.

This is mostly a scripted change:

$ grep -rl NITEMS | xargs sed -i s/NITEMS/countof/;

Apart from the scripted changes, I've adjusted white-space alignment,
and of course the definition at "lib/sizeof.h".

Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf#subsubsection.0.6.5.4.5>
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf#section.0.7.21>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
19 files changed:
lib/adds.h
lib/audit_help.c
lib/fs/readlink/readlinknul.h
lib/must_be.h
lib/sizeof.h
lib/string/sprintf/snprintf.h
lib/string/sprintf/stpeprintf.h
lib/string/strcpy/stpecpy.h
lib/string/strcpy/strncat.h
lib/string/strcpy/strncpy.h
lib/string/strcpy/strtcpy.h
lib/string/strdup/strndupa.h
lib/string/strdup/xstrndup.h
lib/string/strftime.h
lib/time/day_to_str.h
lib/utmp.c
src/login_nopam.c
tests/unit/test_snprintf.c
tests/unit/test_strtcpy.c