lib/attr.h: Add ATTR_STRING() attribute macro

It signals that a function parameter is a string _before_ the call.

Suggested-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2023-11-26 18:38:40 +01:00
committed by Iker Pedrosa
parent 1c464d9a2d
commit a61cf0068b

View File

@@ -21,5 +21,11 @@
# define ATTR_MALLOC(deallocator)
#endif
#if (__GNUC__ >= 14)
# define ATTR_STRING(...) [[gnu::null_terminated_string_arg(__VA_ARGS__)]]
#else
# define ATTR_STRING(...)
#endif
#endif // include guard