Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] Fix warnings
@ 2018-04-04  8:59 Gleb
  2018-04-10 22:13 ` [tarantool-patches] " Alexander Turenko
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb @ 2018-04-04  8:59 UTC (permalink / raw)
  To: tarantool-patches

Ensure -Werror -Wall set for the whole src/.
Fix warnings which have been find with -Werror and -Wall.
Add new building target RelWithDebInfoWError.
Change building target on RelWithDebInfoWError in Ci.
Fixes #3238
---
-Issue from https://github.com/tarantool/tarantool/issues/3238.
-Source from https://github.com/tarantool/tarantool/tree/gh-3238-check-warnings.
 .travis.mk                 |  4 ++--
 cmake/compiler.cmake       |  9 ++++++++-
 src/box/sql/alter.c        |  1 +
 src/box/sql/pragma.c       |  4 ++--
 src/box/vy_read_iterator.c |  2 +-
 src/box/xrow.c             | 10 +++++++---
 src/httpc.c                |  2 +-
 src/lua/init.c             |  3 ++-
 src/say.c                  | 10 ++++++----
 9 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/.travis.mk b/.travis.mk
index 95713e1..2d24256 100644
--- a/.travis.mk
+++ b/.travis.mk
@@ -39,7 +39,7 @@ deps_ubuntu:
 		lcov ruby tcl
 
 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:
 	pip install -r test-run/requirements.txt --user
 
 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 05d33ab..6ec5f93 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -251,12 +251,19 @@ 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.
+    # 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")
         AND HAVE_STD_C11 AND HAVE_STD_CXX11)
         add_compile_flags("C;CXX" "-Werror")
     endif()
+
+    if ((${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfoWError")
+        AND HAVE_STD_C11 AND HAVE_STD_CXX11)
+        add_compile_flags("C;CXX" "-Werror")
+        message("Trouble Release")
+    endif()
 endmacro(enable_tnt_compile_flags)
 
 if (HAVE_OPENMP)
diff --git a/src/box/sql/alter.c b/src/box/sql/alter.c
index a52ba8d..ea4e195 100644
--- a/src/box/sql/alter.c
+++ b/src/box/sql/alter.c
@@ -157,6 +157,7 @@ sqlite3AlterFinishAddColumn(Parse * pParse, Token * pColDef)
 	if (pParse->nErr || db->mallocFailed)
 		return;
 	assert(v != 0);
+	(void) v;
 	pNew = pParse->pNewTable;
 	assert(pNew);
 
diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
index 23b4c73..1a6314a 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -257,7 +257,6 @@ sqlite3Pragma(Parse * pParse, Token * pId,	/* First part of [schema.]id field */
 	char *zLeft = 0;	/* Nul-terminated UTF-8 string <id> */
 	char *zRight = 0;	/* Nul-terminated UTF-8 string <value>, or NULL */
 	char *zTable = 0;	/* Nul-terminated UTF-8 string <value2> or NULL */
-	int rc;			/* return value form SQLITE_FCNTL_PRAGMA */
 	sqlite3 *db = pParse->db;	/* The database connection */
 	Vdbe *v = sqlite3GetVdbe(pParse);	/* Prepared statement */
 	const PragmaName *pPragma;	/* The pragma */
@@ -521,8 +520,9 @@ sqlite3Pragma(Parse * pParse, Token * pId,	/* First part of [schema.]id field */
 		box_tuple_t *tuple;
 		box_iterator_t* iter;
 		iter = box_index_iterator(space_id, 0,ITER_ALL, key_buf, key_end);
-		rc = box_iterator_next(iter, &tuple);
+		int rc = box_iterator_next(iter, &tuple);
 		assert(rc==0);
+		(void) rc;
 		for (i = 0; tuple!=NULL; i++, box_iterator_next(iter, &tuple)){
 			/* 1 is name field number */
 			const char *str = tuple_field_cstr(tuple, 1);
diff --git a/src/box/vy_read_iterator.c b/src/box/vy_read_iterator.c
index a265f58..93681a8 100644
--- a/src/box/vy_read_iterator.c
+++ b/src/box/vy_read_iterator.c
@@ -552,7 +552,7 @@ vy_read_iterator_next_lsn(struct vy_read_iterator *itr, struct tuple **ret)
 {
 	uint32_t i;
 	bool unused;
-	struct vy_read_src *src;
+	struct vy_read_src *src = NULL;
 
 	assert(itr->curr_stmt != NULL);
 	assert(itr->curr_src < itr->skipped_src);
diff --git a/src/box/xrow.c b/src/box/xrow.c
index 3ef3d82..d2a0e02 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -301,6 +301,7 @@ iproto_reply_vclock(struct obuf *out, uint64_t sync, uint32_t schema_version,
 			     size - IPROTO_HEADER_LEN);
 
 	char *ptr = obuf_alloc(out, size);
+	(void) ptr;
 	assert(ptr == buf);
 	return 0;
 }
@@ -339,9 +340,12 @@ iproto_write_error(int fd, const struct error *e, uint32_t schema_version,
 			     schema_version, sizeof(body) + msg_len);
 
 	body.v_data_len = mp_bswap_u32(msg_len);
-	(void) write(fd, header, sizeof(header));
-	(void) write(fd, &body, sizeof(body));
-	(void) write(fd, e->errmsg, msg_len);
+	ssize_t r1 = write(fd, header, sizeof(header));
+	ssize_t r2 = write(fd, &body, sizeof(body));
+	ssize_t r3 = write(fd, e->errmsg, msg_len);
+	(void) r1;
+	(void) r2;
+	(void) r3;
 }
 
 int
diff --git a/src/httpc.c b/src/httpc.c
index 633e688..a720cf3 100644
--- a/src/httpc.c
+++ b/src/httpc.c
@@ -249,7 +249,7 @@ httpc_set_low_speed_limit(struct httpc_request *req, long low_speed_limit)
 void
 httpc_set_verbose(struct httpc_request *req, bool curl_verbose)
 {
-	curl_easy_setopt(req->curl_request.easy, CURLOPT_VERBOSE, curl_verbose);
+	curl_easy_setopt(req->curl_request.easy, CURLOPT_VERBOSE, (long) curl_verbose);
 }
 
 void
diff --git a/src/lua/init.c b/src/lua/init.c
index 76e978c..89765e5 100644
--- a/src/lua/init.c
+++ b/src/lua/init.c
@@ -279,7 +279,8 @@ tarantool_lua_setpaths(struct lua_State *L)
 {
 	const char *home = getenv("HOME");
 	char cwd[PATH_MAX] = {'\0'};
-	getcwd(cwd, sizeof(cwd));
+	char *buf = getcwd(cwd, sizeof(cwd));
+	(void) buf;
 	lua_getglobal(L, "package");
 	int top = lua_gettop(L);
 
diff --git a/src/say.c b/src/say.c
index b92514d..0d2fab2 100644
--- a/src/say.c
+++ b/src/say.c
@@ -853,7 +853,7 @@ say_default(int level, const char *filename, int line, const char *error,
 			     line, error, format, ap);
 	if (level == S_FATAL && log_default->fd != STDERR_FILENO) {
 		ssize_t r = write(STDERR_FILENO, buf, total);
-		(void) r;                       /* silence gcc warning */
+		(void) r; /* silence gcc warning */
 	}
 
 	va_end(ap);
@@ -1040,13 +1040,15 @@ log_vsay(struct log *log, int level, const char *filename, int line,
 		break;
 	case SAY_LOGGER_SYSLOG:
 		write_to_syslog(log, total);
-		if (level == S_FATAL && log->fd != STDERR_FILENO)
-			(void) write(STDERR_FILENO, buf, total);
+		if (level == S_FATAL && log->fd != STDERR_FILENO) {
+			ssize_t r = write(STDERR_FILENO, buf, total);
+			(void) r;                       /* silence gcc warning */
+		}
 		break;
 	case SAY_LOGGER_BOOT:
 	{
 		ssize_t r = write(STDERR_FILENO, buf, total);
-		(void) r;                       /* silence gcc warning */
+		(void) r; /* silence gcc warning */
 		break;
 	}
 	default:
-- 
2.7.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tarantool-patches] Re: [PATCH] Fix warnings
  2018-04-04  8:59 [tarantool-patches] [PATCH] Fix warnings Gleb
@ 2018-04-10 22:13 ` Alexander Turenko
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Turenko @ 2018-04-10 22:13 UTC (permalink / raw)
  To: Gleb Skiba, Nikita Pettik; +Cc: tarantool-patches

Hi Gleb!

Please, remove set(CMAKE_C(XX)_FLAGS) from src/box/sql/CMakeLists.txt,
because it becomes redundant.

Travis-CI fails on your commit on say unit test. It seems it was fixed
in recent 2.0 branch, please rebase on 2.0 and make sure CI is passed.

The patch generally looks good for me except notes above and below.

Nikita, can you look into the patch?

On Wed, Apr 04, 2018 at 11:59:44AM +0300, Gleb wrote:

> Ensure -Werror -Wall set for the whole src/.
> Fix warnings which have been find with -Werror and -Wall.
> Add new building target RelWithDebInfoWError.
> Change building target on RelWithDebInfoWError in Ci.
> Fixes #3238

Separate 'Fixes #xxxx' with newline for readability.

Ci -> CI.

> index 05d33ab..6ec5f93 100644
> --- a/cmake/compiler.cmake
> +++ b/cmake/compiler.cmake
> @@ -251,12 +251,19 @@ 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.
> +    # 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")
>          AND HAVE_STD_C11 AND HAVE_STD_CXX11)
>          add_compile_flags("C;CXX" "-Werror")
>      endif()
> +
> +    if ((${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfoWError")
> +        AND HAVE_STD_C11 AND HAVE_STD_CXX11)
> +        add_compile_flags("C;CXX" "-Werror")
> +        message("Trouble Release")
> +    endif()
>  endmacro(enable_tnt_compile_flags)

Please, remove the message.

> @@ -1040,13 +1040,15 @@ log_vsay(struct log *log, int level, const char *filename, int line,
>  		break;
>  	case SAY_LOGGER_SYSLOG:
>  		write_to_syslog(log, total);
> -		if (level == S_FATAL && log->fd != STDERR_FILENO)
> -			(void) write(STDERR_FILENO, buf, total);
> +		if (level == S_FATAL && log->fd != STDERR_FILENO) {
> +			ssize_t r = write(STDERR_FILENO, buf, total);
> +			(void) r;                       /* silence gcc warning */
> +		}
>  		break;

Replace 23 spaces before comment with one.

WBR, Alexander Turenko.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-10 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04  8:59 [tarantool-patches] [PATCH] Fix warnings Gleb
2018-04-10 22:13 ` [tarantool-patches] " Alexander Turenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox