[tarantool-patches] [PATCH] Add -Werror for CI (1.10 part)

Alexander Turenko alexander.turenko at tarantool.org
Fri Sep 21 19:41:35 MSK 2018


Added MAKE_BUILD_TYPE=RelWithDebInfoWError option, which means enabling
-DNDEBUG=1, -O2 and -Wall -Wextra -Werror. This ensures we have clean
release build without warnings.

Fixed found -Wunused-variable and -Wunused-parameter warnings.

Part of #3238.
---

branch: https://github.com/tarantool/tarantool/tree/Totktonada/gh-3238-add-werror-for-ci-1.10
issue: https://github.com/tarantool/tarantool/issues/3238

Please, push it into 1.10 branch if the changes look good for you.

Note: there is second part of the patchset (for 2.0 branch) with fixes
for SQL code, I'll send it in reply to this message.

 .travis.mk           | 4 ++--
 cmake/compiler.cmake | 9 +++++----
 src/box/xrow.c       | 2 ++
 src/trivia/util.h    | 2 +-
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/.travis.mk b/.travis.mk
index 23f804cde..88335474c 100644
--- a/.travis.mk
+++ b/.travis.mk
@@ -40,7 +40,7 @@ deps_ubuntu:
 		lcov ruby
 
 test_ubuntu: deps_ubuntu
-	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfoWError
 	make -j8
 	cd test && /usr/bin/python test-run.py -j 1
 
@@ -49,7 +49,7 @@ deps_osx:
 	brew install openssl readline curl icu4c --force
 
 test_osx: deps_osx
-	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo
+	cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfoWError
 	# Increase the maximum number of open file descriptors on macOS
 	sudo sysctl -w kern.maxfiles=20480 || :
 	sudo sysctl -w kern.maxfilesperproc=20480 || :
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index f4bacca30..4062d13ec 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -286,10 +286,11 @@ macro(enable_tnt_compile_flags)
     add_definitions("-D__STDC_LIMIT_MACROS=1")
     add_definitions("-D__STDC_CONSTANT_MACROS=1")
 
-    # Only add -Werror if it's a debug build, done by developers.
-    # Release builds should not cause extra trouble.
-    if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug")
-        AND HAVE_STD_C11 AND HAVE_STD_CXX11)
+    # Only add -Werror if it's a Debug or RelWithDebInfoWError build, done by
+    # developers. Release builds should not cause extra trouble.
+    if (((${CMAKE_BUILD_TYPE} STREQUAL "Debug") OR
+        (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfoWError")) AND
+        HAVE_STD_C11 AND HAVE_STD_CXX11)
         add_compile_flags("C;CXX" "-Werror")
     endif()
 endmacro(enable_tnt_compile_flags)
diff --git a/src/box/xrow.c b/src/box/xrow.c
index 7a35d0db1..881ce53fc 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -335,6 +335,7 @@ iproto_reply_vclock(struct obuf *out, const struct vclock *vclock,
 			     size - IPROTO_HEADER_LEN);
 
 	char *ptr = obuf_alloc(out, size);
+	(void) ptr;
 	assert(ptr == buf);
 	return 0;
 }
@@ -373,6 +374,7 @@ iproto_reply_vote(struct obuf *out, const struct ballot *ballot,
 			     size - IPROTO_HEADER_LEN);
 
 	char *ptr = obuf_alloc(out, size);
+	(void) ptr;
 	assert(ptr == buf);
 	return 0;
 }
diff --git a/src/trivia/util.h b/src/trivia/util.h
index fce73a27a..78281c1d1 100644
--- a/src/trivia/util.h
+++ b/src/trivia/util.h
@@ -49,7 +49,7 @@ extern "C" {
 #ifndef NDEBUG
 #define TRASH(ptr) memset(ptr, '#', sizeof(*ptr))
 #else
-#define TRASH(ptr)
+#define TRASH(ptr) (void) (ptr)
 #endif
 
 #ifndef MAX
-- 
2.19.0





More information about the Tarantool-patches mailing list