From: Adam C. Emerson Date: Tue, 11 Mar 2025 21:06:13 +0000 (-0400) Subject: rgw: Make use of VLAs an error X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2ac4d3d2fa57e69393f3b9043ae758fe77f4a078;p=ceph.git rgw: Make use of VLAs an error Signed-off-by: Adam C. Emerson --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c0732cb43eef..7c18ac8aef45 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,6 +130,7 @@ CHECK_CXX_COMPILER_FLAG("-Wredundant-move" COMPILER_SUPPORTS_REDUNDANT_MOVE) if(COMPILER_SUPPORTS_REDUNDANT_MOVE) add_compile_options($<$:-Wredundant-move>) endif() +CHECK_CXX_COMPILER_FLAG("-Werror=vla" COMPILER_SUPPORTS_VLA_ERROR) if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) if(WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10) diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index d42e2b099be5..27448f4c52fa 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -295,6 +295,12 @@ if(COMPILER_SUPPORTS_WARN_IMPLICIT_CONST_INT_FLOAT_CONVERSION) HAVE_WARN_IMPLICIT_CONST_INT_FLOAT_CONVERSION) endif() +if(COMPILER_SUPPORTS_VLA_ERROR) + # Will be picked up by anyone including rgw_common + target_compile_options(rgw_common PUBLIC + $<$:-Werror=vla>) +endif() + target_link_libraries(rgw_common PRIVATE legacy-option-headers @@ -490,12 +496,15 @@ set(rgw_schedulers_srcs add_library(rgw_schedulers STATIC ${rgw_schedulers_srcs}) target_link_libraries(rgw_schedulers PUBLIC dmclock::dmclock Boost::context) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(rgw_schedulers PRIVATE + $<$:-Werror=vla>) +endif() set(radosgw_srcs rgw_main.cc) add_executable(radosgw ${radosgw_srcs}) - if(WITH_RADOSGW_ARROW_FLIGHT) # target_compile_definitions(radosgw PUBLIC WITH_ARROW_FLIGHT) target_compile_definitions(rgw_common PUBLIC WITH_ARROW_FLIGHT) @@ -574,6 +583,9 @@ target_link_libraries(radosgw-token legacy-option-headers librados global) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(radosgw-token PRIVATE $<$:-Werror=vla>) +endif() install(TARGETS radosgw-token DESTINATION bin) if(WITH_RADOSGW_RADOS) diff --git a/src/rgw/driver/dbstore/CMakeLists.txt b/src/rgw/driver/dbstore/CMakeLists.txt index f401c912f675..0226c3afb020 100644 --- a/src/rgw/driver/dbstore/CMakeLists.txt +++ b/src/rgw/driver/dbstore/CMakeLists.txt @@ -25,6 +25,9 @@ set(dbstore_mgr_srcs ) add_library(dbstore_lib ${dbstore_srcs}) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(dbstore_lib PRIVATE $<$:-Werror=vla>) +endif() target_include_directories(dbstore_lib PUBLIC "${CMAKE_SOURCE_DIR}/src/rgw" PUBLIC "${CMAKE_SOURCE_DIR}/src/rgw/store/rados" @@ -60,6 +63,9 @@ endif() include_directories(${CMAKE_INCLUDE_DIR}) add_library(dbstore STATIC ${dbstore_mgr_srcs}) target_link_libraries(dbstore ${CMAKE_LINK_LIBRARIES}) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(dbstore PRIVATE $<$:-Werror=vla>) +endif() # testing purpose set(dbstore_main_srcs @@ -69,3 +75,6 @@ set (CMAKE_LINK_LIBRARIES ${CMAKE_LINK_LIBRARIES} dbstore) add_executable(dbstore-bin ${dbstore_main_srcs}) add_dependencies(dbstore-bin dbstore) target_link_libraries(dbstore-bin ${CMAKE_LINK_LIBRARIES}) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(dbstore-bin PRIVATE $<$:-Werror=vla>) +endif() diff --git a/src/rgw/driver/dbstore/sqlite/CMakeLists.txt b/src/rgw/driver/dbstore/sqlite/CMakeLists.txt index 909765e3058b..37c0f14fdbba 100644 --- a/src/rgw/driver/dbstore/sqlite/CMakeLists.txt +++ b/src/rgw/driver/dbstore/sqlite/CMakeLists.txt @@ -14,3 +14,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SQLITE_COMPILE_FLAGS}") add_library(sqlite_db STATIC ${sqlite_db_srcs}) target_link_libraries(sqlite_db sqlite3 dbstore_lib rgw_common) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(sqlite_db PRIVATE $<$:-Werror=vla>) +endif() diff --git a/src/rgw/driver/dbstore/tests/CMakeLists.txt b/src/rgw/driver/dbstore/tests/CMakeLists.txt index 4e60dcf5ee2b..af8400774d20 100644 --- a/src/rgw/driver/dbstore/tests/CMakeLists.txt +++ b/src/rgw/driver/dbstore/tests/CMakeLists.txt @@ -11,7 +11,13 @@ include_directories(${CMAKE_INCLUDE_DIR}) add_executable(unittest_dbstore_tests ${dbstore_tests_srcs}) target_link_libraries(unittest_dbstore_tests ${CMAKE_LINK_LIBRARIES}) add_ceph_unittest(unittest_dbstore_tests) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(unittest_dbstore_tests PRIVATE $<$:-Werror=vla>) +endif() add_executable(unittest_dbstore_mgr_tests dbstore_mgr_tests.cc) target_link_libraries(unittest_dbstore_mgr_tests dbstore gtest_main) add_ceph_unittest(unittest_dbstore_mgr_tests) +if(COMPILER_SUPPORTS_VLA_ERROR) + target_compile_options(unittest_dbstore_mgr_tests PRIVATE $<$:-Werror=vla>) +endif()