From f2e7f24daaa43c0927130b6ed02c3ed17689b3ca Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 6 Sep 2024 13:36:15 +0200 Subject: Work around a gcc warning It seems that annotating sprintf with `write` makes gcc unhappy, as its analyser is unable to understand that we're checking if `__b != -1` before calling `__orig_snprintf`, so let's comment this annotation for now. --- include/stdio.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include/stdio.h') diff --git a/include/stdio.h b/include/stdio.h index c1070a8..3e31f29 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -286,7 +286,7 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, } __fh_format(printf, 2, 3) -__fh_access(write_only, 1) +//__fh_access(write_only, 1) __fh_access(read_only, 2) _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) { @@ -296,13 +296,13 @@ _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) __fh_size_t __b = __fh_bos(__s, 0); int __r; - if (__b != (__fh_size_t)-1) { - __r = __orig_snprintf(__s, __b, __f, __builtin_va_arg_pack()); - if (__r != -1 && (__fh_size_t)__r >= __b) - __builtin_trap(); - } else { - __r = __orig_sprintf(__s, __f, __builtin_va_arg_pack()); + if (__b == (__fh_size_t)-1) { + return __orig_sprintf(__s, __f, __builtin_va_arg_pack()); } + + __r = __orig_snprintf(__s, __b, __f, __builtin_va_arg_pack()); + if (__r != -1 && (__fh_size_t)__r >= __b) + __builtin_trap(); return __r; #endif } -- cgit v1.3