From 2b3150db944076f7dc4300bb73c766bf4d7517b1 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Sun, 2 Jun 2019 14:05:28 +1000 Subject: 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 --- ctdb/common/logging.c | 14 +++++++------- ctdb/common/path.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'ctdb/common') 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; } -- cgit v1.2.1