fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit 2c610a26730540ff917cf83dd9dc5387184001b2
parent f3ff539ee4d739d704415f3ff17d72a822bb3d9b
Author: jvoisin <julien.voisin@dustri.org>
Date:   Tue, 22 Aug 2023 20:08:52 +0200

Clean up some includes

- Remove a superfluous `#if defined(__has_builtin)` since it's already
  accounted for in include/fortify-headers.h
- Replace `_FORTIFY_FD_POS0` with the already existing `_FORTIFY_POS0`
- Factorise some duplicate code into a macro

Diffstat:
Minclude/stdio.h | 2--
Minclude/sys/select.h | 15+++++----------
2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h @@ -153,7 +153,6 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, return __r; } -#if defined(__has_builtin) #if __has_builtin(__builtin_va_arg_pack) /* clang is missing __builtin_va_arg_pack, so we cannot use these impls @@ -203,7 +202,6 @@ _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) } #endif /* __has_builtin(__builtin_va_arg_pack) */ -#endif /* defined(__has_builtin) */ #ifdef __cplusplus } diff --git a/include/sys/select.h b/include/sys/select.h @@ -28,14 +28,10 @@ __extension__ extern "C" { #endif -#ifdef __clang__ -#define _FORTIFY_FD_POS0 const __attribute__((__pass_object_size__(0))) -#else -#define _FORTIFY_FD_POS0 -#endif +#define _STI static __inline__ \ + __attribute__((__always_inline__,__gnu_inline__,__artificial__)) -static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) -void __fortify_FD_CLR(int __f, fd_set * _FORTIFY_FD_POS0 __s) +_STI void __fortify_FD_CLR(int __f, fd_set * _FORTIFY_POS0 __s) { size_t __b = __bos(__s, 0); @@ -44,8 +40,7 @@ void __fortify_FD_CLR(int __f, fd_set * _FORTIFY_FD_POS0 __s) FD_CLR(__f, __s); } -static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) -void __fortify_FD_SET(int __f, fd_set * _FORTIFY_FD_POS0 __s) +_STI void __fortify_FD_SET(int __f, fd_set * _FORTIFY_POS0 __s) { size_t __b = __bos(__s, 0); @@ -54,7 +49,7 @@ void __fortify_FD_SET(int __f, fd_set * _FORTIFY_FD_POS0 __s) FD_SET(__f, __s); } -#undef _FORTIFY_FD_POS0 +#undef _STI #undef FD_CLR #define FD_CLR(fd, set) __fortify_FD_CLR(fd, set)