]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Hide [[gnu::malloc(deallocator)]] in a macro
authorAlejandro Colomar <alx@kernel.org>
Wed, 28 Sep 2022 21:09:19 +0000 (23:09 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 5 Dec 2022 09:47:19 +0000 (10:47 +0100)
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>
lib/defines.h
lib/prototypes.h

index d01f691e04769929c9af7fdbd00caa17509f763f..7950cdfaa1471ac651a5e121036daad302ef8dfc 100644 (file)
@@ -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
index 4c293aff065d962d0e02375cf2ed9a4a76c2effa..885c7391cca932d2e5cb195696b824c76823369f 100644 (file)
@@ -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 */