]> git.ipfire.org Git - thirdparty/shadow.git/commit
zustr2stp.h: Add ZUSTR2STP() macro
authorAlejandro Colomar <alx@kernel.org>
Sun, 30 Jul 2023 16:45:47 +0000 (18:45 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 1 Sep 2023 07:39:23 +0000 (09:39 +0200)
commit983a8446337abd80cce3883a864b82367b78d52f
tree40b7fd1f16d2bbfa466e0d95ec65becbc7fc335b
parent02b1471d5bef083726bcfdf493cd344974de4009
zustr2stp.h: Add ZUSTR2STP() macro

It's a wrapper around zustr2stp() that calls SIZEOF_ARRAY() internally.
The function call is usually --in our code base, always-- called with an
array as the second argument.  For such an argument, one should call
SIZEOF_ARRAY().  To avoid mistakes, and simplify usage, let's add this
macro that does it internally.

BTW, this macro doesn't have any issues of double evaluation, because
sizeof() doesn't evaluate its argument (unless it's a VLA, but then
the static_assert(3) within SIZEOF_ARRAY() makes sure VLAs are not
allowed).

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/zustr2stp.h