From a61cf0068bf8b56dec5a1d42c9e9701199fcbb0f Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 26 Nov 2023 18:38:40 +0100 Subject: [PATCH] lib/attr.h: Add ATTR_STRING() attribute macro It signals that a function parameter is a string _before_ the call. Suggested-by: Serge Hallyn Signed-off-by: Alejandro Colomar --- lib/attr.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/attr.h b/lib/attr.h index 56a2e0c9d..b1f153c7e 100644 --- a/lib/attr.h +++ b/lib/attr.h @@ -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 -- 2.47.2