33abc8bcd9
It wraps strlcpy(3bsd) so that it performs some steps that one might forget, or might be prone to accidents: - It calculates the size of the destination buffer, and makes sure it's an array (otherwise, using sizeof(dst) would be very bad). - It calculates if there's truncation, returning an easy-to-use value. 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>
2.9 KiB
2.9 KiB