From b3b4bdcda40380048b302c6dd957396340b88d6c Mon Sep 17 00:00:00 2001 From: eifrah-aws Date: Fri, 3 Jan 2025 03:44:41 +0200 Subject: [PATCH] CMake: fail on warnings (#1503) When building with `CMake` (especially the targets `valkey-cli`, `valkey-server` and `valkey-benchmark`) it is possible to have a successful build while having warnings. This PR fixes this - which is aligned with how the `Makefile` is working today: - Enable `-Wall` + `-Werror` for valkey targets - Fixed warning in valkey-cli:jsonStringOutput method Signed-off-by: Eran Ifrah --- cmake/Modules/ValkeySetup.cmake | 3 +++ src/valkey-cli.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/cmake/Modules/ValkeySetup.cmake b/cmake/Modules/ValkeySetup.cmake index 8a4d4da1c..77360844f 100644 --- a/cmake/Modules/ValkeySetup.cmake +++ b/cmake/Modules/ValkeySetup.cmake @@ -93,6 +93,9 @@ macro (valkey_build_and_install_bin target sources ld_flags libs link_name) target_link_libraries(${target} execinfo) endif () + # Enable all warnings + fail on warning + target_compile_options(${target} PRIVATE -Werror -Wall) + # Install cli tool and create a redis symbolic link valkey_install_bin(${target}) valkey_create_symlink(${target} ${link_name}) diff --git a/src/valkey-cli.c b/src/valkey-cli.c index 4416e0943..0a4f1affa 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -2040,6 +2040,8 @@ static sds jsonStringOutput(sds out, const char *p, int len, int mode) { } else { assert(0); } + /* Silence compiler warning */ + return NULL; } static sds cliFormatReplyJson(sds out, redisReply *r, int mode) {