From bdcc565875ff2c6bcdfbb3540d68b3ca49925a7f Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Thu, 2 Oct 2014 19:38:39 +0400 Subject: [PATCH] Fix a few warnings of the release build. --- src/box/lua/call.cc | 5 ++++- src/find_path.c | 3 ++- src/fiob.c | 4 ++-- src/lib/small/slab_arena.c | 2 +- src/random.c | 3 ++- src/tarantool.cc | 3 ++- test/unit/fiob.c | 15 ++++++++++----- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/box/lua/call.cc b/src/box/lua/call.cc index 0319da6163..6d7a6289be 100644 --- a/src/box/lua/call.cc +++ b/src/box/lua/call.cc @@ -481,7 +481,10 @@ struct SetuidGuard SetuidGuard::SetuidGuard(const char *name, uint32_t name_len, struct user *user, uint8_t access) :setuid(false) + ,orig_auth_token(GUEST) /* silence gnu warning */ + ,orig_uid(GUEST) { + /* * If the user has universal access, don't bother with setuid. * No special check for ADMIN user is necessary @@ -516,7 +519,7 @@ SetuidGuard::SetuidGuard(const char *name, uint32_t name_len, } if (func->setuid) { /** Remember and change the current user id. */ - setuid = func->setuid; + setuid = true; orig_auth_token = user->auth_token; orig_uid = user->uid; session_set_user(session(), func->auth_token, func->uid); diff --git a/src/find_path.c b/src/find_path.c index 749596573d..4c8e8fce3a 100644 --- a/src/find_path.c +++ b/src/find_path.c @@ -41,7 +41,8 @@ find_path(const char *argv0) if (rc == -1) snprintf(buf, sizeof(buf) - 1, "%s", getenv("_")); } - realpath(buf, path); + if (realpath(buf, path) == NULL) + snprintf(path, sizeof(path), "%s", buf); found = true; return path; } diff --git a/src/fiob.c b/src/fiob.c index b5800cbf3a..5b767deede 100644 --- a/src/fiob.c +++ b/src/fiob.c @@ -274,8 +274,8 @@ fiob_open(const char *path, const char *mode) flags |= O_DIRECT; #endif bsize = O_DIRECT_BSIZE; - posix_memalign(&buf, 4096, bsize); - if (!buf) { + int res = posix_memalign(&buf, 4096, bsize); + if (res || !buf) { errno = ENOMEM; return NULL; } diff --git a/src/lib/small/slab_arena.c b/src/lib/small/slab_arena.c index 0d3a6e301e..5e54359785 100644 --- a/src/lib/small/slab_arena.c +++ b/src/lib/small/slab_arena.c @@ -44,7 +44,7 @@ munmap_checked(void *addr, size_t size) { if (munmap(addr, size)) { char buf[64]; - strerror_r(errno, buf, sizeof(buf)); + (void) strerror_r(errno, buf, sizeof(buf)); fprintf(stderr, "Error in munmap(%p, %zu): %s\n", addr, size, buf); assert(false); diff --git a/src/random.c b/src/random.c index 2b4e6679a9..103e3af22f 100644 --- a/src/random.c +++ b/src/random.c @@ -54,7 +54,8 @@ random_init(void) if (flags != -1) fcntl(rfd, F_SETFD, flags | FD_CLOEXEC); - read(rfd, &seed, sizeof(seed)); + ssize_t res = read(rfd, &seed, sizeof(seed)); + (void) res; srand: srandom(seed); srand(seed); diff --git a/src/tarantool.cc b/src/tarantool.cc index c7c4830871..d254059955 100644 --- a/src/tarantool.cc +++ b/src/tarantool.cc @@ -506,7 +506,8 @@ tarantool_free(void) if (time(NULL) == 0) { /* never executed */ extern void *ffi_symbols[]; - write(0, ffi_symbols, 0); + ssize_t res = write(0, ffi_symbols, 0); + (void) res; } } diff --git a/test/unit/fiob.c b/test/unit/fiob.c index aa66d1187c..02dce5f772 100644 --- a/test/unit/fiob.c +++ b/test/unit/fiob.c @@ -165,7 +165,8 @@ main(void) done = 0; for (i = 0; i < 1000000 + 1; i++) { buf[0] = 0; - fgets(buf, 4096, f); + char *res = fgets(buf, 4096, f); + (void) res; if (strcmp(buf, "Hello, world\n") == 0) done++; } @@ -195,12 +196,16 @@ main(void) done = 0; for (i = 0; i < 1000000 + 1; i++) { memset(buf, 0, 4096); - fgets(buf, 4096, f); + char *res = fgets(buf, 4096, f); + (void) res; if (strcmp(buf, "Hello, world\n") == 0) done++; -/* else */ -/* fprintf(stderr, "# wrong line %zu: %s", */ -/* i, buf); */ +#if 0 + else { + fprintf(stderr, "# wrong line %zu: %s", + i, buf); + } +#endif } is(done, 1000000 + 1, "all records were written properly"); -- GitLab