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 <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar authored and Iker Pedrosa committed 2022-12-05 10:47:19 +01:00
1 parent 554f86bafa
commit ab91ec10b4
2 files changed
+7 -1

No files matched your search

+6
View File
@@ -330,6 +330,12 @@ extern char *strerror ();
/* Maximum length of passwd entry */ /* Maximum length of passwd entry */
#define PASSWD_ENTRY_MAX_LENGTH 32768 #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 #ifdef HAVE_SECURE_GETENV
# define shadow_getenv(name) secure_getenv(name) # define shadow_getenv(name) secure_getenv(name)
# else # else
+1 -1
View File
@@ -47,7 +47,7 @@ extern int expire (const struct passwd *, /*@null@*/const struct spwd *);
/* agetpass.c */ /* agetpass.c */
extern void erase_pass(char *pass); extern void erase_pass(char *pass);
[[gnu::malloc(erase_pass)]] ATTR_MALLOC(erase_pass)
extern char *agetpass(const char *prompt); extern char *agetpass(const char *prompt);
/* isexpired.c */ /* isexpired.c */