ctdb-tools: Fix signed/unsigned conversion by declaring as size_t
authorMartin Schwenke <martin@meltin.net>
Tue, 28 May 2019 00:57:49 +0000 (10:57 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 5 Jun 2019 10:25:49 +0000 (10:25 +0000)
All the top-level callers pass size_t.

Drop the ternary operator.  The value of hsize is always positive
because it is unsigned.

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

index d33480ce8fe59645e05f04432eff07713dca2f65..98a1b5167510bc876b3dfdc35921ee15dd72aac8 100644 (file)
@@ -96,7 +96,7 @@ static int usage(const char* cmd)
 static int
 ltdb_traverse(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT*, TDB_DATA, TDB_DATA,
                                          struct ctdb_ltdb_header*, void *),
-             void *state, int hsize, bool skip_empty);
+             void *state, size_t hsize, bool skip_empty);
 
 struct write_record_ctx {
        TDB_CONTEXT* tdb;
@@ -125,7 +125,10 @@ static void dump_header_nop(struct dump_record_ctx* c,
                            struct ctdb_ltdb_header* h)
 {}
 
-static int dump_db(const char* iname, FILE* ofile, int hsize, bool dump_header,
+static int dump_db(const char* iname,
+                  FILE* ofile,
+                  size_t hsize,
+                  bool dump_header,
                   bool empty)
 {
        int ret = -1;
@@ -307,12 +310,12 @@ ltdb_traverse_fn(TDB_CONTEXT* tdb, TDB_DATA key, TDB_DATA val,
 static int ltdb_traverse(TDB_CONTEXT *tdb,
                         int (*fn)(TDB_CONTEXT*, TDB_DATA, TDB_DATA,
                                   struct ctdb_ltdb_header*, void *),
-                        void *state, int hsize, bool skip_empty)
+                        void *state, size_t hsize, bool skip_empty)
 {
        struct ltdb_traverse_ctx ctx = {
                .fn = fn,
                .state = state,
-               .hsize = hsize < 0 ? sizeof(struct ctdb_ltdb_header) : hsize,
+               .hsize = hsize,
                .skip_empty = skip_empty,
                .nempty = 0,
        };