From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 1371E22852 for ; Mon, 23 Apr 2018 13:08:50 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6_CC8gnNo5A4 for ; Mon, 23 Apr 2018 13:08:50 -0400 (EDT) Received: from smtp53.i.mail.ru (smtp53.i.mail.ru [94.100.177.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 49BAF22727 for ; Mon, 23 Apr 2018 13:08:49 -0400 (EDT) Received: by smtp53.i.mail.ru with esmtpa (envelope-from ) id 1fAexL-0003uh-C7 for tarantool-patches@freelists.org; Mon, 23 Apr 2018 20:08:47 +0300 From: "Gleb" (Redacted sender "gleb-skiba" for DMARC) Subject: [tarantool-patches] [PATCH v2] Fix warnings Date: Mon, 23 Apr 2018 20:08:41 +0300 Message-Id: <1524503321-23830-1-git-send-email-gleb-skiba@mail.ru> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Ensure -Werror -Wall set for the whole src/. Fix warnings which have been found with -Werror and -Wall. Add new build target RelWithDebInfoWError. Change build target on RelWithDebInfoWError in CI. Fixes #3238 --- .travis.mk | 4 ++-- cmake/compiler.cmake | 8 +++++++- src/box/space_def.c | 2 ++ src/box/sql/CMakeLists.txt | 3 --- src/box/sql/alter.c | 1 + src/box/sql/insert.c | 5 +++-- src/box/sql/pragma.c | 4 ++-- src/box/vy_read_iterator.c | 2 +- src/box/xrow.c | 13 ++++++++++--- src/httpc.c | 2 +- src/lua/init.c | 4 +++- src/say.c | 7 +++++-- 12 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.travis.mk b/.travis.mk index 393d78f..2328e0d 100644 --- a/.travis.mk +++ b/.travis.mk @@ -40,7 +40,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: 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 05d33ab..12fc335 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -251,12 +251,18 @@ 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") + endif() endmacro(enable_tnt_compile_flags) if (HAVE_OPENMP) diff --git a/src/box/space_def.c b/src/box/space_def.c index 22bd3ca..3f11088 100644 --- a/src/box/space_def.c +++ b/src/box/space_def.c @@ -130,6 +130,7 @@ space_def_dup(const struct space_def *src) * allocation refactoring. */ assert(expr_pos_old == expr_pos); + (void) expr_pos_old; expr_pos += sql_expr_sizeof(e, 0); ret->fields[i].default_value_expr = e; } @@ -216,6 +217,7 @@ space_def_new(uint32_t id, uint32_t uid, uint32_t exact_field_count, * allocation refactoring. */ assert(expr_pos_old == expr_pos); + (void) expr_pos_old; expr_pos += sql_expr_sizeof(e, 0); def->fields[i].default_value_expr = e; } diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt index 678eb4c..526d9fe 100644 --- a/src/box/sql/CMakeLists.txt +++ b/src/box/sql/CMakeLists.txt @@ -4,9 +4,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(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/box/sql/alter.c b/src/box/sql/alter.c index b30a973..6c4952a 100644 --- a/src/box/sql/alter.c +++ b/src/box/sql/alter.c @@ -156,6 +156,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/insert.c b/src/box/sql/insert.c index f04496a..b96adb1 100644 --- a/src/box/sql/insert.c +++ b/src/box/sql/insert.c @@ -48,15 +48,16 @@ sqlite3OpenTable(Parse * pParse, /* Generate code into this VDBE */ Table * pTab, /* The table to be opened */ int opcode) /* OP_OpenRead or OP_OpenWrite */ { - Vdbe *v; - v = sqlite3GetVdbe(pParse); + Vdbe *v = sqlite3GetVdbe(pParse); assert(opcode == OP_OpenWrite || opcode == OP_OpenRead); + (void) opcode; Index *pPk = sqlite3PrimaryKeyIndex(pTab); assert(pPk != 0); assert(pPk->tnum == pTab->tnum); emit_open_cursor(pParse, iCur, pPk->tnum); sqlite3VdbeSetP4KeyInfo(pParse, pPk); VdbeComment((v, "%s", pTab->zName)); + (void) v; } /* diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index a2a6391..491cc67 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -256,7 +256,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ char *zLeft = 0; /* Nul-terminated UTF-8 string */ char *zRight = 0; /* Nul-terminated UTF-8 string , or NULL */ char *zTable = 0; /* Nul-terminated UTF-8 string 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 */ @@ -523,8 +522,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 2cad233..fea2c46 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 64dc625..a9920c3 100644 --- a/src/box/xrow.c +++ b/src/box/xrow.c @@ -306,6 +306,7 @@ iproto_reply_request_vote(struct obuf *out, uint64_t sync, char *ptr = obuf_alloc(out, size); assert(ptr == buf); + (void) ptr; return 0; } @@ -343,9 +344,15 @@ 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 unused = write(fd, header, sizeof(header)); + /* Silence gcc warning. */ + (void) unused; + unused = write(fd, &body, sizeof(body)); + /* Silence gcc warning. */ + (void) unused; + unused = write(fd, e->errmsg, msg_len); + /* Silence gcc warning. */ + (void) unused; } 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..7345490 100644 --- a/src/lua/init.c +++ b/src/lua/init.c @@ -279,7 +279,9 @@ tarantool_lua_setpaths(struct lua_State *L) { const char *home = getenv("HOME"); char cwd[PATH_MAX] = {'\0'}; - getcwd(cwd, sizeof(cwd)); + char *unused = getcwd(cwd, sizeof(cwd)); + /* Silence gcc warning. */ + (void) unused; lua_getglobal(L, "package"); int top = lua_gettop(L); diff --git a/src/say.c b/src/say.c index 4312408..fadb9ac 100644 --- a/src/say.c +++ b/src/say.c @@ -1130,8 +1130,11 @@ 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) safe_write(STDERR_FILENO, buf, total); + if (level == S_FATAL && log->fd != STDERR_FILENO) { + ssize_t unused = safe_write(STDERR_FILENO, buf, total); + /* Silence gcc warning. */ + (void) unused; + } break; case SAY_LOGGER_BOOT: { -- 2.7.4