From: Martin Schwenke Date: Sun, 2 Jun 2019 04:05:28 +0000 (+1000) Subject: ctdb-common: Fix signed/unsigned comparisons by casting X-Git-Tag: ldb-2.0.5~482 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2b3150db944076f7dc4300bb73c766bf4d7517b1;p=thirdparty%2Fsamba.git ctdb-common: Fix signed/unsigned comparisons by casting In one case, given triviality of change, add missing braces and fix whitespace. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/common/logging.c b/ctdb/common/logging.c index fd763170304..a4321b68ba9 100644 --- a/ctdb/common/logging.c +++ b/ctdb/common/logging.c @@ -63,7 +63,7 @@ bool debug_level_parse(const char *log_string, int *log_level) if (isdigit(log_string[0])) { int level = atoi(log_string); - if (level >= 0 && level < ARRAY_SIZE(log_string_map)) { + if (level >= 0 && (size_t)level < ARRAY_SIZE(log_string_map)) { *log_level = level; return true; } @@ -253,12 +253,12 @@ static int debug_level_to_priority(int level) }; int priority; - if( level >= ARRAY_SIZE(priority_map) || level < 0) - priority = LOG_DEBUG; - else - priority = priority_map[level]; - - return priority; + if ((size_t)level >= ARRAY_SIZE(priority_map) || level < 0) { + priority = LOG_DEBUG; + } else { + priority = priority_map[level]; + } + return priority; } struct syslog_log_state { diff --git a/ctdb/common/path.c b/ctdb/common/path.c index 69e606b4ede..ea3b08f4b2e 100644 --- a/ctdb/common/path.c +++ b/ctdb/common/path.c @@ -89,7 +89,7 @@ static bool path_construct(char *path, const char *subdir) subdir); } - if (len >= sizeof(p)) { + if ((size_t)len >= sizeof(p)) { return false; }