This is an automated email from the ASF dual-hosted git repository.

twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new e7809396 Fix unused-variable error for lower gcc version due to 
structure bindings (#2265)
e7809396 is described below

commit e780939689ff1b031a44640a00a91ecbd85e7439
Author: detached <[email protected]>
AuthorDate: Mon Apr 22 22:11:12 2024 +0800

    Fix unused-variable error for lower gcc version due to structure bindings 
(#2265)
    
    Co-authored-by: hulk <[email protected]>
---
 CMakeLists.txt       | 11 ++++++++++-
 src/server/server.cc |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d508d4ea..944b5509 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -212,7 +212,16 @@ add_library(kvrocks_objs OBJECT ${KVROCKS_SRCS})
 target_include_directories(kvrocks_objs PUBLIC src src/common src/vendor 
${PROJECT_BINARY_DIR} ${Backtrace_INCLUDE_DIR})
 target_compile_features(kvrocks_objs PUBLIC cxx_std_17)
 target_compile_options(kvrocks_objs PUBLIC -Wall -Wpedantic -Wsign-compare 
-Wreturn-type -fno-omit-frame-pointer)
-target_compile_options(kvrocks_objs PUBLIC -Werror=unused-result 
-Werror=unused-variable)
+target_compile_options(kvrocks_objs PUBLIC -Werror=unused-result)
+
+# disable unused-variable check on GCC < 8 due to the structure bindings
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?format=multiple&id=81767
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION 
VERSION_LESS 8)
+    target_compile_options(kvrocks_objs PUBLIC -Wno-error=unused-variable)
+else()
+    target_compile_options(kvrocks_objs PUBLIC -Werror=unused-variable)
+endif()
+
 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
     target_compile_options(kvrocks_objs PUBLIC -Wno-pedantic)
 elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID 
STREQUAL "AppleClang"))
diff --git a/src/server/server.cc b/src/server/server.cc
index 9408b90c..e482aefb 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -1636,7 +1636,7 @@ StatusOr<std::unique_ptr<redis::Commander>> 
Server::LookupAndCreateCommand(const
   auto cmd = cmd_attr->factory();
   cmd->SetAttributes(cmd_attr);
 
-  return cmd;
+  return std::move(cmd);
 }
 
 Status Server::ScriptExists(const std::string &sha) {

Reply via email to