Commit aa2b1432b3 for openssl.org
commit aa2b1432b3245b81a08852380b237b5795b46a96
Author: Bob Beck <beck@openssl.org>
Date: Thu Jun 18 11:24:17 2026 -0600
Simplify printf-attribute guards in bio.h.in and test/testutil/output.h.
Now that C99 is the base level, and we are no longer supporting old
GCC's, The ossl_bio__printf__ / ossl_test__printf__ indirection only existed
to pick the gnu_printf attribute over the printf attribute for MinGW's MS-CRT printf, but
MinGW is already excluded by the outer guard, so we can use the modern attribute
everywhere this code runs.
Spotted by idrassi on review, thanks!.
Reviewed-by: Milan Broz <mbroz@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Fri Jul 10 11:47:19 2026
(Merged from https://github.com/openssl/openssl/pull/31677)
diff --git a/include/openssl/bio.h.in b/include/openssl/bio.h.in
index 7912dcaa82..c2990efde4 100644
--- a/include/openssl/bio.h.in
+++ b/include/openssl/bio.h.in
@@ -932,33 +932,20 @@ void BIO_copy_next_retry(BIO *b);
*/
#define ossl_bio__attr__(x)
-#if defined(__GNUC__) && defined(__STDC_VERSION__) \
- && !defined(__MINGW32__) && !defined(__MINGW64__) \
+#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__MINGW64__) \
&& !defined(__APPLE__)
-/*
- * Because we support the 'z' modifier, which made its appearance in C99,
- * we can't use __attribute__ with pre C99 dialects.
- */
-#if __STDC_VERSION__ >= 199901L
#undef ossl_bio__attr__
#define ossl_bio__attr__ __attribute__
-#if __GNUC__ * 10 + __GNUC_MINOR__ >= 44
-#define ossl_bio__printf__ __gnu_printf__
-#else
-#define ossl_bio__printf__ __printf__
-#endif
-#endif
#endif
int BIO_printf(BIO *bio, const char *format, ...)
- ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3)));
+ ossl_bio__attr__((__format__(__printf__, 2, 3)));
int BIO_vprintf(BIO *bio, const char *format, va_list args)
- ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0)));
+ ossl_bio__attr__((__format__(__printf__, 2, 0)));
int BIO_snprintf(char *buf, size_t n, const char *format, ...)
- ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4)));
+ ossl_bio__attr__((__format__(__printf__, 3, 4)));
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
- ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));
+ ossl_bio__attr__((__format__(__printf__, 3, 0)));
#undef ossl_bio__attr__
-#undef ossl_bio__printf__
BIO_METHOD *BIO_meth_new(int type, const char *name);
void BIO_meth_free(BIO_METHOD *biom);
diff --git a/test/testutil.h b/test/testutil.h
index b38791b287..f606ff1f75 100644
--- a/test/testutil.h
+++ b/test/testutil.h
@@ -322,18 +322,11 @@ const OPTIONS *test_get_options(void);
*/
#define PRINTF_FORMAT(a, b)
-#if defined(__GNUC__) && defined(__STDC_VERSION__) \
- && !defined(__MINGW32__) && !defined(__MINGW64__) \
+#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__MINGW64__) \
&& !defined(__APPLE__)
-/*
- * Because we support the 'z' modifier, which made its appearance in C99,
- * we can't use __attribute__ with pre C99 dialects.
- */
-#if __STDC_VERSION__ >= 199901L
#undef PRINTF_FORMAT
#define PRINTF_FORMAT(a, b) __attribute__((format(printf, a, b)))
#endif
-#endif
#define DECLARE_COMPARISON(type, name, opname) \
int test_##name##_##opname(const char *, int, \
diff --git a/test/testutil/output.h b/test/testutil/output.h
index cee3026b11..e4f6058ac7 100644
--- a/test/testutil/output.h
+++ b/test/testutil/output.h
@@ -13,22 +13,10 @@
#include <stdarg.h>
#define ossl_test__attr__(x)
-#if defined(__GNUC__) && defined(__STDC_VERSION__) \
- && !defined(__MINGW32__) && !defined(__MINGW64__) \
+#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__MINGW64__) \
&& !defined(__APPLE__)
-/*
- * Because we support the 'z' modifier, which made its appearance in C99,
- * we can't use __attribute__ with pre C99 dialects.
- */
-#if __STDC_VERSION__ >= 199901L
#undef ossl_test__attr__
#define ossl_test__attr__ __attribute__
-#if __GNUC__ * 10 + __GNUC_MINOR__ >= 44
-#define ossl_test__printf__ __gnu_printf__
-#else
-#define ossl_test__printf__ __printf__
-#endif
-#endif
#endif
/*
* The basic I/O functions used internally by the test framework. These
@@ -39,13 +27,13 @@ void test_close_streams(void);
void test_adjust_streams_tap_level(int level);
/* The following ALL return the number of characters written */
int test_vprintf_stdout(const char *fmt, va_list ap)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
+ ossl_test__attr__((__format__(__printf__, 1, 0)));
int test_vprintf_tapout(const char *fmt, va_list ap)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
+ ossl_test__attr__((__format__(__printf__, 1, 0)));
int test_vprintf_stderr(const char *fmt, va_list ap)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
+ ossl_test__attr__((__format__(__printf__, 1, 0)));
int test_vprintf_taperr(const char *fmt, va_list ap)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
+ ossl_test__attr__((__format__(__printf__, 1, 0)));
/* These return failure or success */
int test_flush_stdout(void);
int test_flush_tapout(void);
@@ -54,15 +42,14 @@ int test_flush_taperr(void);
/* Commodity functions. There's no need to override these */
int test_printf_stdout(const char *fmt, ...)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
+ ossl_test__attr__((__format__(__printf__, 1, 2)));
int test_printf_tapout(const char *fmt, ...)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
+ ossl_test__attr__((__format__(__printf__, 1, 2)));
int test_printf_stderr(const char *fmt, ...)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
+ ossl_test__attr__((__format__(__printf__, 1, 2)));
int test_printf_taperr(const char *fmt, ...)
- ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
+ ossl_test__attr__((__format__(__printf__, 1, 2)));
-#undef ossl_test__printf__
#undef ossl_test__attr__
#endif /* OSSL_TESTUTIL_OUTPUT_H */