]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Make use of VLAs an error
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 11 Mar 2025 21:06:13 +0000 (17:06 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Thu, 26 Mar 2026 04:07:21 +0000 (00:07 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/CMakeLists.txt
src/rgw/CMakeLists.txt
src/rgw/driver/dbstore/CMakeLists.txt
src/rgw/driver/dbstore/sqlite/CMakeLists.txt
src/rgw/driver/dbstore/tests/CMakeLists.txt

index c0732cb43eef6a3448b807de1975a2176be9ae35..7c18ac8aef452c1cb9ab28505e902ad59f3fa605 100644 (file)
@@ -130,6 +130,7 @@ CHECK_CXX_COMPILER_FLAG("-Wredundant-move" COMPILER_SUPPORTS_REDUNDANT_MOVE)
 if(COMPILER_SUPPORTS_REDUNDANT_MOVE)
   add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-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)
index d42e2b099be5a1723d2888a9d606cfa9ce17bc38..27448f4c52fa7ee3b70108777e3f9d93178732ae 100644 (file)
@@ -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
+    $<$<COMPILE_LANGUAGE:CXX>:-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
+    $<$<COMPILE_LANGUAGE:CXX>:-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 $<$<COMPILE_LANGUAGE:CXX>:-Werror=vla>)
+endif()
 install(TARGETS radosgw-token DESTINATION bin)
 
 if(WITH_RADOSGW_RADOS)
index f401c912f6751827bf9e8e3264ba09a45152f844..0226c3afb02039b4bdf9bd338908d72fe571449e 100644 (file)
@@ -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 $<$<COMPILE_LANGUAGE:CXX>:-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 $<$<COMPILE_LANGUAGE:CXX>:-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 $<$<COMPILE_LANGUAGE:CXX>:-Werror=vla>)
+endif()
index 909765e3058b6fdda7324fc4537527ab9b1e58c7..37c0f14fdbbac3d30c3b3380b0323dae09e6f455 100644 (file)
@@ -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 $<$<COMPILE_LANGUAGE:CXX>:-Werror=vla>)
+endif()
index 4e60dcf5ee2b4c00e541ba5570ebb40ee42a4c9c..af8400774d209c5f1f10df7e67adb3193ead0636 100644 (file)
@@ -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 $<$<COMPILE_LANGUAGE:CXX>:-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 $<$<COMPILE_LANGUAGE:CXX>:-Werror=vla>)
+endif()