From: Richard Levitte Date: Mon, 12 Sep 2022 15:29:53 +0000 (+0200) Subject: Checking __STDC_VERSION__ rather than __STRICT_ANSI__ X-Git-Tag: openssl-3.2.0-alpha1~2099 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1104a3a2dd4351af85cf48f677691a414ffc3a2;p=thirdparty%2Fopenssl.git Checking __STDC_VERSION__ rather than __STRICT_ANSI__ `__STRICT_ANSI__` is a gnuish flag macro that indicates if `-ansi` was given on the command line. To check the C version, it's better to check the macro `__STDC_VERSION__`. Reviewed-by: Hugo Landau Reviewed-by: Shane Lontis Reviewed-by: Tomas Mraz Reviewed-by: Todd Short (Merged from https://github.com/openssl/openssl/pull/19197) --- diff --git a/apps/lib/log.c b/apps/lib/log.c index 94a91949eab..7cf5ad5f893 100644 --- a/apps/lib/log.c +++ b/apps/lib/log.c @@ -56,18 +56,31 @@ static void log_with_prefix(const char *prog, const char *fmt, va_list ap) BIO_free(pre); } +/* + * Unfortunately, C before C99 does not define va_copy, so we must + * check if it can be assumed to be present. We do that with an internal + * antifeature macro. + * C versions since C94 define __STDC_VERSION__, so it's enough to + * check its existence and value. + */ +#undef OSSL_NO_C99 +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ + 0 < 199900L +# define OSSL_NO_C99 +#endif + void trace_log_message(int category, const char *prog, int level, const char *fmt, ...) { va_list ap; va_start(ap, fmt); -#ifdef __STRICT_ANSI__ /* unfortuantely, ANSI does not define va_copy */ + +#ifdef OSSL_NO_C99 if (verbosity >= level) category = -1; /* disabling trace output in addition to logging */ #endif if (category >= 0 && OSSL_trace_enabled(category)) { BIO *out = OSSL_trace_begin(category); -#ifndef __STRICT_ANSI__ +#ifndef OSSL_NO_C99 va_list ap_copy; va_copy(ap_copy, ap);