From a6962a80ba2185b144c1c8b1d9a8d566e6e4c74a Mon Sep 17 00:00:00 2001 From: Michael Barker Date: Mon, 17 Jun 2024 18:37:00 +1200 Subject: [PATCH] [C] Use C++ compliant flexible array member. --- CMakeLists.txt | 2 +- aeron-driver/src/main/c/aeron_driver_conductor_proxy.c | 2 +- aeron-driver/src/main/c/aeron_driver_conductor_proxy.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb016f3aeb3..1d5cb1f4e1c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ add_definitions(-DAERON_VERSION_GITSHA="${AERON_VERSION_GITSHA}") # all UNIX-based platform compiler flags if (UNIX) - add_compile_options(-Wall -Wpedantic -Wextra -Wno-unused-parameter -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer) + add_compile_options(-Wall -Wpedantic -Wextra -Wno-unused-parameter -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fstrict-flex-arrays=1) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "11.0") add_compile_options(-Wno-error=maybe-uninitialized) diff --git a/aeron-driver/src/main/c/aeron_driver_conductor_proxy.c b/aeron-driver/src/main/c/aeron_driver_conductor_proxy.c index 528a87f050e..610e049c771 100644 --- a/aeron-driver/src/main/c/aeron_driver_conductor_proxy.c +++ b/aeron-driver/src/main/c/aeron_driver_conductor_proxy.c @@ -267,7 +267,7 @@ void aeron_driver_conductor_proxy_on_publication_error( int32_t error_length, const uint8_t *error_text) { - uint8_t buffer[sizeof(aeron_command_publication_error_t) + AERON_ERROR_MAX_MESSAGE_LENGTH + 1]; + uint8_t buffer[offsetof(aeron_command_publication_error_t, error_text[AERON_ERROR_MAX_MESSAGE_LENGTH + 1])]; aeron_command_publication_error_t *error = (aeron_command_publication_error_t *)buffer; error_length = error_length <= AERON_ERROR_MAX_MESSAGE_LENGTH ? error_length : AERON_ERROR_MAX_MESSAGE_LENGTH; diff --git a/aeron-driver/src/main/c/aeron_driver_conductor_proxy.h b/aeron-driver/src/main/c/aeron_driver_conductor_proxy.h index 1d925e77331..151b88834c8 100644 --- a/aeron-driver/src/main/c/aeron_driver_conductor_proxy.h +++ b/aeron-driver/src/main/c/aeron_driver_conductor_proxy.h @@ -106,7 +106,7 @@ struct aeron_command_publication_error_stct int64_t registration_id; int32_t error_code; int32_t error_length; - uint8_t error_text[]; + uint8_t error_text[1]; }; typedef struct aeron_command_publication_error_stct aeron_command_publication_error_t;