[tarantool-patches] [PATCH] Fix RelWithDebInfoWError warnings on 2.0

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


Fixed warnings from -Wunused-parameter, -Wunused-variable,
-Wunused-but-set-variable.

Fixed -Wsometimes-uninitialized on clang in where.c.

Removed -Wall -Wextra -Werror from SQL CMakeLists.txt, because it is set
by tarantool itself and is redundant.

Fixes #3238.
---

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

Please, push it to 2.0 if the changes look good for you.

Note: this part of the patchset can be pushed to 2.0 before or just
after of 1.10 part.

 src/box/space_def.c        | 2 ++
 src/box/sql/CMakeLists.txt | 3 ---
 src/box/sql/build.c        | 2 +-
 src/box/sql/insert.c       | 5 +++--
 src/box/sql/pragma.c       | 6 +++---
 src/box/sql/vdbeaux.c      | 2 +-
 src/box/sql/vdbemem.c      | 1 +
 src/box/sql/where.c        | 2 +-
 8 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/box/space_def.c b/src/box/space_def.c
index 542289ead..69b92c5c1 100644
--- a/src/box/space_def.c
+++ b/src/box/space_def.c
@@ -153,6 +153,7 @@ space_def_dup(const struct space_def *src)
 			struct Expr *e = src->fields[i].default_value_expr;
 			if (e != NULL) {
 				char *expr_pos_old = expr_pos;
+				(void) expr_pos_old;
 				e = sql_expr_dup(sql_get(), e, 0, &expr_pos);
 				assert(e != NULL);
 				/* Note: due to SQL legacy
@@ -233,6 +234,7 @@ space_def_new(uint32_t id, uint32_t uid, uint32_t exact_field_count,
 			struct Expr *e = def->fields[i].default_value_expr;
 			if (e != NULL) {
 				char *expr_pos_old = expr_pos;
+				(void) expr_pos_old;
 				e = sql_expr_dup(sql_get(), e, 0, &expr_pos);
 				assert(e != NULL);
 				/* Note: due to SQL legacy
diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt
index 1f852424a..73726bd9a 100644
--- a/src/box/sql/CMakeLists.txt
+++ b/src/box/sql/CMakeLists.txt
@@ -2,9 +2,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
   add_definitions(-DSQLITE_DEBUG=1)
   add_definitions(-DSQLITE_ENABLE_SELECTTRACE)
   add_definitions(-DSQLITE_ENABLE_WHERETRACE)
-
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
 endif()
 
 set(EXT_SRC_DIR ${CMAKE_SOURCE_DIR}/extra)
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index 60b49df12..4ff3f6b87 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -2379,7 +2379,7 @@ constraint_is_named(const char *name)
 void
 sql_create_index(struct Parse *parse, struct Token *token,
 		 struct SrcList *tbl_name, struct ExprList *col_list,
-		 struct Token *start, enum sort_order sort_order,
+		 MAYBE_UNUSED struct Token *start, enum sort_order sort_order,
 		 bool if_not_exist, enum sql_index_type idx_type) {
 	/* The index to be created. */
 	struct index *index = NULL;
diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index 03f4e1b14..e1a4481fa 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -45,11 +45,12 @@
  */
 void
 sqlite3OpenTable(Parse * pParse,	/* Generate code into this VDBE */
-		 int iCur,	/* The cursor number of the table */
+		 int iCur,		/* The cursor number of the table */
 		 struct space *space,	/* The table to be opened */
-		 int opcode)	/* OP_OpenRead or OP_OpenWrite */
+		 MAYBE_UNUSED int opcode)	/* OP_OpenRead or OP_OpenWrite */
 {
 	Vdbe *v;
+	(void) v;
 	v = sqlite3GetVdbe(pParse);
 	assert(opcode == OP_OpenWrite || opcode == OP_OpenRead);
 	assert(space->index_count > 0);
diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
index 4f64ab6f2..b3fdd06c6 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -430,7 +430,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 */
@@ -526,8 +525,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);
-		assert(rc==0);
+		int rc = box_iterator_next(iter, &tuple);
+		(void) rc;
+		assert(rc == 0);
 		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/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index c843bc786..c270059c5 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -2271,7 +2271,7 @@ sql_txn_begin(Vdbe *p)
 }
 
 Savepoint *
-sql_savepoint(Vdbe *p, const char *zName)
+sql_savepoint(MAYBE_UNUSED Vdbe *p, const char *zName)
 {
 	assert(p);
 	size_t nName = zName ? strlen(zName) + 1 : 0;
diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index ef70442b3..8edbd83a5 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -1597,6 +1597,7 @@ sql_stat4_column(struct sqlite3 *db, const char *record, uint32_t col_num,
 	const char *a = record;
 	assert(mp_typeof(a[0]) == MP_ARRAY);
 	uint32_t col_cnt = mp_decode_array(&a);
+	(void) col_cnt;
 	assert(col_cnt > col_num);
 	for (uint32_t i = 0; i < col_num; i++)
 		mp_next(&a);
diff --git a/src/box/sql/where.c b/src/box/sql/where.c
index a9cbcda0d..ed9d93394 100644
--- a/src/box/sql/where.c
+++ b/src/box/sql/where.c
@@ -4609,10 +4609,10 @@ sqlite3WhereBegin(Parse * pParse,	/* The parser context */
 				iIndexCur = pLevel->iTabCur;
 				op = 0;
 			} else if (pWInfo->eOnePass != ONEPASS_OFF) {
+				iIndexCur = iAuxArg;
 				if (pTabItem->pTab->space->index_count != 0) {
 					uint32_t iid = 0;
 					struct index *pJ = pTabItem->pTab->space->index[iid];
-					iIndexCur = iAuxArg;
 					assert(wctrlFlags &
 					       WHERE_ONEPASS_DESIRED);
 					while (pJ->def->iid != idx_def->iid) {
-- 
2.19.0





More information about the Tarantool-patches mailing list