From b725fe1944b45406676ea3aff333ae3085a848d9 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 10 Mar 2023 22:24:24 +0000 Subject: [PATCH] lib: silence clang/gcc -Wvla warnings in brotli headers brotli v1.0.0 throughout current latest v1.0.9 and latest master [1] trigger this warning. It happened with CMake and GNU Make. autotools builds avoid it with the `convert -I options to -isystem` macro. llvm/clang: ``` In file included from ./curl/lib/content_encoding.c:36: ./brotli/x64-ucrt/usr/include/brotli/decode.h:204:34: warning: variable length array used [-Wvla] const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)], ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./brotli/x64-ucrt/usr/include/brotli/port.h:253:34: note: expanded from macro 'BROTLI_ARRAY_PARAM' ^~~~~~ In file included from ./curl/lib/content_encoding.c:36: ./brotli/x64-ucrt/usr/include/brotli/decode.h:206:48: warning: variable length array used [-Wvla] uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]); ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ ./brotli/x64-ucrt/usr/include/brotli/port.h:253:35: note: expanded from macro 'BROTLI_ARRAY_PARAM' ~^~~~~ ``` gcc: ``` In file included from ./curl/lib/content_encoding.c:36: ./brotli/x64-ucrt/usr/include/brotli/decode.h:204:5: warning: ISO C90 forbids variable length array 'encoded_buffer' [-Wvla] 204 | const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)], | ^~~~~ ./brotli/x64-ucrt/usr/include/brotli/decode.h:206:5: warning: ISO C90 forbids variable length array 'decoded_buffer' [-Wvla] 206 | uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]); | ^~~~~~~ ``` [1] https://github.com/google/brotli/commit/ed1995b6bda19244070ab5d331111f16f67c8054 Reviewed-by: Daniel Stenberg Reviewed-by: Marcel Raad Closes #10738 --- lib/content_encoding.c | 8 ++++++++ lib/version.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 2bd4fef648..f8524837d0 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -33,7 +33,15 @@ #endif #ifdef HAVE_BROTLI +#if defined(__GNUC__) +/* Ignore -Wvla warnings in brotli headers */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvla" +#endif #include +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif #endif #ifdef HAVE_ZSTD diff --git a/lib/version.c b/lib/version.c index eaf9e46842..c036e97178 100644 --- a/lib/version.c +++ b/lib/version.c @@ -62,7 +62,15 @@ #endif #ifdef HAVE_BROTLI +#if defined(__GNUC__) +/* Ignore -Wvla warnings in brotli headers */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvla" +#endif #include +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif #endif #ifdef HAVE_ZSTD -- 2.47.3