From ac1b26d7450ac3dda7473f460703292a6ba46f40 Mon Sep 17 00:00:00 2001 From: Roman Tsisyk <roman@tsisyk.com> Date: Thu, 10 Jul 2014 17:40:30 +0400 Subject: [PATCH] Fix clang warnings --- cmake/BuildLibEIO.cmake | 1 + src/find_path.c | 5 +++-- src/random.c | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmake/BuildLibEIO.cmake b/cmake/BuildLibEIO.cmake index 582c96fe17..3f4c59a924 100644 --- a/cmake/BuildLibEIO.cmake +++ b/cmake/BuildLibEIO.cmake @@ -5,6 +5,7 @@ macro(libeio_build) set(eio_compile_flags "${eio_compile_flags} -Wno-unused-result") set(eio_compile_flags "${eio_compile_flags} -Wno-dangling-else") + set(eio_compile_flags "${eio_compile_flags} -Wno-unused-value") set(eio_compile_flags "${eio_compile_flags} -DENABLE_BUNDLED_LIBEIO=1") set(eio_compile_flags "${eio_compile_flags} -DEIO_STACKSIZE=0") diff --git a/src/find_path.c b/src/find_path.c index f076723805..749596573d 100644 --- a/src/find_path.c +++ b/src/find_path.c @@ -21,7 +21,7 @@ find_path(const char *argv0) return path; char buf[PATH_MAX]; - uint32_t size = PATH_MAX - 1; + size_t size = PATH_MAX - 1; if (argv0[0] == '/') snprintf(buf, size, "%s", argv0); else { @@ -35,7 +35,8 @@ find_path(const char *argv0) snprintf(buf, size, "%s", getexecname()); rc = 0; #elif defined(__APPLE__) - rc = _NSGetExecutablePath(buf, &size); + uint32_t usize = size; + rc = _NSGetExecutablePath(buf, &usize); #endif if (rc == -1) snprintf(buf, sizeof(buf) - 1, "%s", getenv("_")); diff --git a/src/random.c b/src/random.c index 629b3aeb48..2b4e6679a9 100644 --- a/src/random.c +++ b/src/random.c @@ -51,9 +51,8 @@ random_init(void) } int flags = fcntl(rfd, F_GETFD); - if (flags < 0) - goto srand; - fcntl(rfd, F_SETFD, flags | FD_CLOEXEC); + if (flags != -1) + fcntl(rfd, F_SETFD, flags | FD_CLOEXEC); read(rfd, &seed, sizeof(seed)); srand: @@ -72,10 +71,11 @@ random_free(void) void random_bytes(char *buf, size_t size) { + size_t generated = 0; + if (rfd == -1) goto rand; - size_t generated = 0; int attempt = 0; while (generated < size) { ssize_t n = read(rfd, buf + generated, size - generated); -- GitLab