From 3a8db9fed3d730e55983747e2b7d32d304734307 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Fri, 15 Apr 2016 22:11:40 +0300 Subject: [PATCH] mdbx: -Wextra and fixes. Change-Id: I9f373e66f8f5f7cf3b29b5246eb2c67e4a49a460 --- Makefile | 4 ++-- mdb_chk.c | 13 ++++++++++--- mdb_copy.c | 1 + mdb_dump.c | 3 ++- mtest0.c | 2 ++ mtest1.c | 2 ++ mtest2.c | 2 ++ mtest3.c | 2 ++ mtest4.c | 2 ++ mtest5.c | 2 ++ mtest6.c | 2 ++ wbench.c | 3 +++ yota_test1.c | 3 +++ yota_test2.c | 3 +++ 14 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 142c73fe..054768f5 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ prefix ?= /usr/local mandir ?= $(prefix)/man CC ?= gcc -XCFLAGS ?= -CFLAGS ?= -O2 -ggdb3 -Wall -Werror -DNDEBUG=1 +XCFLAGS ?= -DNDEBUG=1 -DMDB_DEBUG=0 +CFLAGS ?= -O2 -g -Wall -Werror -Wextra CFLAGS += -pthread $(XCFLAGS) IOARENA ?= ../ioarena.git/@BUILD/src/ioarena diff --git a/mdb_chk.c b/mdb_chk.c index 52c35048..3f83ff97 100644 --- a/mdb_chk.c +++ b/mdb_chk.c @@ -50,6 +50,7 @@ flagbit dbflags[] = { static volatile sig_atomic_t gotsignal; static void signal_hanlder( int sig ) { + (void) sig; gotsignal = 1; } @@ -228,6 +229,8 @@ static size_t problems_pop(struct problem* list) { static int pgvisitor(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi, const char* type, int nentries, int payload_bytes, int header_bytes, int unused_bytes) { + (void) ctx; + if (type) { size_t page_bytes = payload_bytes + header_bytes + unused_bytes; size_t page_size = pgnumber * stat.base.ms_psize; @@ -250,14 +253,14 @@ static int pgvisitor(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi, problem_add("page", pgno, "illegal unused-bytes", "%zu < %i < %zu", 0, unused_bytes, stat.base.ms_psize); - if (header_bytes < sizeof(long) || header_bytes >= stat.base.ms_psize - sizeof(long)) + if (header_bytes < (int) sizeof(long) || (size_t) header_bytes >= stat.base.ms_psize - sizeof(long)) problem_add("page", pgno, "illegal header-length", "%zu < %i < %zu", sizeof(long), header_bytes, stat.base.ms_psize - sizeof(long)); if (payload_bytes < 1) { if (nentries > 0) { problem_add("page", pgno, "zero size-of-entry", "payload %i bytes, %i entries", payload_bytes, nentries); - if (header_bytes + unused_bytes < page_size) { + if ((size_t) header_bytes + unused_bytes < page_size) { /* LY: hush a misuse error */ page_bytes = page_size; } @@ -302,6 +305,9 @@ typedef int (visitor)(size_t record_number, MDB_val *key, MDB_val* data); static int process_db(MDB_dbi dbi, char *name, visitor *handler, int silent); static int handle_userdb(size_t record_number, MDB_val *key, MDB_val* data) { + (void) record_number; + (void) key; + (void) data; return MDB_SUCCESS; } @@ -366,7 +372,8 @@ static int handle_freedb(size_t record_number, MDB_val *key, MDB_val* data) { static int handle_maindb(size_t record_number, MDB_val *key, MDB_val* data) { char *name; - int i, rc; + int rc; + size_t i; name = key->mv_data; for(i = 0; i < key->mv_size; ++i) { diff --git a/mdb_copy.c b/mdb_copy.c index 5d358829..8de6fb5f 100644 --- a/mdb_copy.c +++ b/mdb_copy.c @@ -25,6 +25,7 @@ static void sighandle(int sig) { + (void) sig; } int main(int argc,char * argv[]) diff --git a/mdb_dump.c b/mdb_dump.c index 8e74bfc2..e5e0c12c 100644 --- a/mdb_dump.c +++ b/mdb_dump.c @@ -48,7 +48,8 @@ static volatile sig_atomic_t gotsig; static void dumpsig( int sig ) { - gotsig=1; + (void) sig; + gotsig = 1; } static const char hexc[] = "0123456789abcdef"; diff --git a/mtest0.c b/mtest0.c index 2db8a88b..d47445f1 100644 --- a/mtest0.c +++ b/mtest0.c @@ -44,6 +44,8 @@ int main(int argc,char * argv[]) int env_oflags; struct stat db_stat, exe_stat; + (void) argc; + (void) argv; srand(time(NULL)); count = (rand()%384) + 64; diff --git a/mtest1.c b/mtest1.c index 3157d6d1..68e108a6 100644 --- a/mtest1.c +++ b/mtest1.c @@ -52,6 +52,8 @@ int main(int argc,char * argv[]) int env_oflags; struct stat db_stat, exe_stat; + (void) argc; + (void) argv; srand(time(NULL)); count = (rand()%384) + 64; diff --git a/mtest2.c b/mtest2.c index 1a9bc2b2..1247fecd 100644 --- a/mtest2.c +++ b/mtest2.c @@ -46,6 +46,8 @@ int main(int argc,char * argv[]) int env_oflags; struct stat db_stat, exe_stat; + (void) argc; + (void) argv; srand(time(NULL)); count = (rand()%384) + 64; diff --git a/mtest3.c b/mtest3.c index e8acf454..0c23ef0a 100644 --- a/mtest3.c +++ b/mtest3.c @@ -47,6 +47,8 @@ int main(int argc,char * argv[]) int env_oflags; struct stat db_stat, exe_stat; + (void) argc; + (void) argv; srand(time(NULL)); memset(sval, 0, sizeof(sval)); diff --git a/mtest4.c b/mtest4.c index 949a667c..ff146191 100644 --- a/mtest4.c +++ b/mtest4.c @@ -47,6 +47,8 @@ int main(int argc,char * argv[]) int env_oflags; struct stat db_stat, exe_stat; + (void) argc; + (void) argv; memset(sval, 0, sizeof(sval)); count = 510; diff --git a/mtest5.c b/mtest5.c index 2a756f7b..6dc36126 100644 --- a/mtest5.c +++ b/mtest5.c @@ -47,6 +47,8 @@ int main(int argc,char * argv[]) int env_oflags; struct stat db_stat, exe_stat; + (void) argc; + (void) argv; srand(time(NULL)); memset(sval, 0, sizeof(sval)); diff --git a/mtest6.c b/mtest6.c index ba046355..a1ac3abe 100644 --- a/mtest6.c +++ b/mtest6.c @@ -47,6 +47,8 @@ int main(int argc,char * argv[]) int env_oflags; struct stat db_stat, exe_stat; + (void) argc; + (void) argv; srand(time(NULL)); E(mdb_env_create(&env)); diff --git a/wbench.c b/wbench.c index c7df82ef..f47bd5b7 100644 --- a/wbench.c +++ b/wbench.c @@ -205,6 +205,9 @@ static void wbench(int flags, int mb, int count, int salt) int main(int argc,char * argv[]) { + (void) argc; + (void) argv; + #define SALT 1 #define COUNT 10000 #define SIZE 12 diff --git a/yota_test1.c b/yota_test1.c index 6be26d1d..41b4334d 100644 --- a/yota_test1.c +++ b/yota_test1.c @@ -217,6 +217,9 @@ static void periodic_add_rec() { } int main(int argc, char** argv) { + (void) argc; + (void) argv; + char filename[PATH_MAX]; mkdir(opt_db_path, 0775); diff --git a/yota_test2.c b/yota_test2.c index cf393d3a..aeef6864 100644 --- a/yota_test2.c +++ b/yota_test2.c @@ -240,6 +240,9 @@ static void periodic_stat(void) { //} int main(int argc, char** argv) { + (void) argc; + (void) argv; + char filename[PATH_MAX]; int i; int64_t t;