]> git.ipfire.org Git - thirdparty/shadow.git/commit
sizeof.h: Add SIZEOF_ARRAY() macro
authorAlejandro Colomar <alx@kernel.org>
Sun, 30 Jul 2023 12:29:45 +0000 (14:29 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 1 Sep 2023 07:39:23 +0000 (09:39 +0200)
commite29994218960382fea8854d58e44af3b5a405f94
treed09ae9d0995940c02b6cd8d582e3a287a4a98823
parent49ea7327d96d1f5793fdd9b5c2bd1d6e252b3f6b
sizeof.h: Add SIZEOF_ARRAY() macro

This makes it safe to call sizeof() on an array.  Calling sizeof()
directly on an array is dangerous, because if the array changes to be a
pointer, the behavior will unexpectedly change.  It's the same problem
as with NITEMS().

Link: <https://stackoverflow.com/a/57537491>
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/sizeof.h