20062d
commit 2337e04e21ba6040926ec871e403533f77043c40
20062d
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
20062d
Date:   Thu Feb 2 07:49:02 2023 -0500
20062d
20062d
    cdefs: Limit definition of fortification macros
20062d
    
20062d
    Define the __glibc_fortify and other macros only when __FORTIFY_LEVEL >
20062d
    0.  This has the effect of not defining these macros on older C90
20062d
    compilers that do not have support for variable length argument lists.
20062d
    
20062d
    Also trim off the trailing backslashes from the definition of
20062d
    __glibc_fortify and __glibc_fortify_n macros.
20062d
    
20062d
    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
20062d
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
20062d
20062d
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
20062d
index f3d7efdd2a9320f7..46ec4ef71e14c569 100644
20062d
--- a/misc/sys/cdefs.h
20062d
+++ b/misc/sys/cdefs.h
20062d
@@ -133,6 +133,7 @@
20062d
 # define __glibc_objsize(__o) __bos (__o)
20062d
 #endif
20062d
 
20062d
+#if __USE_FORTIFY_LEVEL > 0
20062d
 /* Compile time conditions to choose between the regular, _chk and _chk_warn
20062d
    variants.  These conditions should get evaluated to constant and optimized
20062d
    away.  */
20062d
@@ -168,7 +169,7 @@
20062d
    ? __ ## f ## _alias (__VA_ARGS__)					      \
20062d
    : (__glibc_unsafe_len (__l, __s, __osz)				      \
20062d
       ? __ ## f ## _chk_warn (__VA_ARGS__, __osz)			      \
20062d
-      : __ ## f ## _chk (__VA_ARGS__, __osz)))			      \
20062d
+      : __ ## f ## _chk (__VA_ARGS__, __osz)))
20062d
 
20062d
 /* Fortify function f, where object size argument passed to f is the number of
20062d
    elements and not total size.  */
20062d
@@ -178,7 +179,8 @@
20062d
    ? __ ## f ## _alias (__VA_ARGS__)					      \
20062d
    : (__glibc_unsafe_len (__l, __s, __osz)				      \
20062d
       ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s))		      \
20062d
-      : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))		      \
20062d
+      : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))
20062d
+#endif
20062d
 
20062d
 #if __GNUC_PREREQ (4,3)
20062d
 # define __warndecl(name, msg) \