From: Alejandro Colomar Date: Wed, 28 Sep 2022 21:09:19 +0000 (+0200) Subject: Hide [[gnu::malloc(deallocator)]] in a macro X-Git-Tag: 4.14.0-rc1~316 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab91ec10b4a42b935183e06df3791f74869ed823;p=thirdparty%2Fshadow.git Hide [[gnu::malloc(deallocator)]] in a macro Clang doesn't implement this attribute and reports an error. Work around it by hiding it in a macro that will be empty in clang. Reported-by: Christian Göttsche Signed-off-by: Alejandro Colomar --- diff --git a/lib/defines.h b/lib/defines.h index d01f691e0..7950cdfaa 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -330,6 +330,12 @@ extern char *strerror (); /* Maximum length of passwd entry */ #define PASSWD_ENTRY_MAX_LENGTH 32768 +#if (__GNUC__ >= 11) && !defined(__clang__) +# define ATTR_MALLOC(deallocator) [[gnu::malloc(deallocator)]] +#else +# define ATTR_MALLOC(deallocator) +#endif + #ifdef HAVE_SECURE_GETENV # define shadow_getenv(name) secure_getenv(name) # else diff --git a/lib/prototypes.h b/lib/prototypes.h index 4c293aff0..885c7391c 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -47,7 +47,7 @@ extern int expire (const struct passwd *, /*@null@*/const struct spwd *); /* agetpass.c */ extern void erase_pass(char *pass); -[[gnu::malloc(erase_pass)]] +ATTR_MALLOC(erase_pass) extern char *agetpass(const char *prompt); /* isexpired.c */