Skip to content

Commit

Permalink
Fix unused-variable error for lower gcc version due to structure bind…
Browse files Browse the repository at this point in the history
…ings (#2265)

Co-authored-by: hulk <[email protected]>
  • Loading branch information
13015517713 and git-hulk committed Apr 22, 2024
1 parent 0e2273a commit e780939
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion src/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e780939

Please sign in to comment.