ctdb-daemon: Avoid signed/unsigned comparison by declaring as unsigned
authorMartin Schwenke <martin@meltin.net>
Thu, 1 Aug 2019 00:55:39 +0000 (10:55 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 14 Aug 2019 09:11:36 +0000 (09:11 +0000)
Compiling with -Wsign-compare complains:

ctdb/server/ctdb_call.c:831:12: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
  831 |  if (count <= ctdb_db->statistics.hot_keys[0].count) {
      |            ^~

and

ctdb/server/ctdb_call.c:844:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
  844 |   if (count <= ctdb_db->statistics.hot_keys[i].count) {
      |             ^~

Found by cs-build.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_call.c

index 346fe89010e59d36572106616ffa6cf351746787..876ae448cca6315868f69b08d8ad1bf840c407c6 100644 (file)
@@ -822,7 +822,7 @@ ctdb_defer_pinned_down_request(struct ctdb_context *ctdb, struct ctdb_db_context
 
 static void
 ctdb_update_db_stat_hot_keys(struct ctdb_db_context *ctdb_db, TDB_DATA key,
-                            int count)
+                            unsigned int count)
 {
        int i, id;
        char *keystr;
@@ -1983,7 +1983,7 @@ static void ctdb_migration_count_handler(TDB_DATA key, uint64_t counter,
 {
        struct ctdb_db_context *ctdb_db = talloc_get_type_abort(
                private_data, struct ctdb_db_context);
-       int value;
+       unsigned int value;
 
        value = (counter < INT_MAX ? counter : INT_MAX);
        ctdb_update_db_stat_hot_keys(ctdb_db, key, value);