public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] cdefs: Limit definition of fortification macros
@ 2023-02-02 12:50 Siddhesh Poyarekar
  0 siblings, 0 replies; only message in thread
From: Siddhesh Poyarekar @ 2023-02-02 12:50 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2337e04e21ba6040926ec871e403533f77043c40

commit 2337e04e21ba6040926ec871e403533f77043c40
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Thu Feb 2 07:49:02 2023 -0500

    cdefs: Limit definition of fortification macros
    
    Define the __glibc_fortify and other macros only when __FORTIFY_LEVEL >
    0.  This has the effect of not defining these macros on older C90
    compilers that do not have support for variable length argument lists.
    
    Also trim off the trailing backslashes from the definition of
    __glibc_fortify and __glibc_fortify_n macros.
    
    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
    Reviewed-by: Florian Weimer <fweimer@redhat.com>

Diff:
---
 misc/sys/cdefs.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 66d6702123..c37a3ff637 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -152,6 +152,7 @@
 # define __glibc_objsize(__o) __bos (__o)
 #endif
 
+#if __USE_FORTIFY_LEVEL > 0
 /* Compile time conditions to choose between the regular, _chk and _chk_warn
    variants.  These conditions should get evaluated to constant and optimized
    away.  */
@@ -187,7 +188,7 @@
    ? __ ## f ## _alias (__VA_ARGS__)					      \
    : (__glibc_unsafe_len (__l, __s, __osz)				      \
       ? __ ## f ## _chk_warn (__VA_ARGS__, __osz)			      \
-      : __ ## f ## _chk (__VA_ARGS__, __osz)))			      \
+      : __ ## f ## _chk (__VA_ARGS__, __osz)))
 
 /* Fortify function f, where object size argument passed to f is the number of
    elements and not total size.  */
@@ -197,7 +198,8 @@
    ? __ ## f ## _alias (__VA_ARGS__)					      \
    : (__glibc_unsafe_len (__l, __s, __osz)				      \
       ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s))		      \
-      : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))		      \
+      : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))
+#endif
 
 #if __GNUC_PREREQ (4,3)
 # define __warnattr(msg) __attribute__((__warning__ (msg)))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-02 12:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 12:50 [glibc] cdefs: Limit definition of fortification macros Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).