From: Martin Schwenke Date: Tue, 28 May 2019 00:57:49 +0000 (+1000) Subject: ctdb-tools: Fix signed/unsigned conversion by declaring as size_t X-Git-Tag: ldb-2.0.5~485 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9869ac1fb7677267426979ab9dadefffe501b84c;p=thirdparty%2Fsamba.git ctdb-tools: Fix signed/unsigned conversion by declaring as size_t 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tools/ltdbtool.c b/ctdb/tools/ltdbtool.c index d33480ce8fe..98a1b516751 100644 --- a/ctdb/tools/ltdbtool.c +++ b/ctdb/tools/ltdbtool.c @@ -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, };