From: Rusty Russell Date: Wed, 20 Oct 2010 03:49:11 +0000 (+1030) Subject: tdb2: 64 bit fixes. X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=3d10865d159072553933fb72394862c884e60079;hp=3b9d55bd9c9180cc94de96bf60f7bfa5d5f8f2cc;ds=sidebyside tdb2: 64 bit fixes. --- diff --git a/ccan/tdb2/check.c b/ccan/tdb2/check.c index c2ca95d0..eb8ddcae 100644 --- a/ccan/tdb2/check.c +++ b/ccan/tdb2/check.c @@ -45,14 +45,15 @@ static bool check_header(struct tdb_context *tdb) if (hdr.hash_test != hash_test) { tdb->log(tdb, TDB_DEBUG_ERROR, tdb->log_priv, "check: hash test %llu should be %llu\n", - hdr.hash_test, hash_test); + (long long)hdr.hash_test, + (long long)hash_test); return false; } if (strcmp(hdr.magic_food, TDB_MAGIC_FOOD) != 0) { tdb->log(tdb, TDB_DEBUG_ERROR, tdb->log_priv, "check: bad magic '%.*s'\n", - sizeof(hdr.magic_food), hdr.magic_food); + (unsigned)sizeof(hdr.magic_food), hdr.magic_food); return false; } @@ -263,7 +264,7 @@ static bool check_hash(struct tdb_context *tdb, if (!check_hash_tree(tdb, offsetof(struct tdb_header, hashtable), TDB_TOPLEVEL_HASH_BITS-TDB_HASH_GROUP_BITS, - 0, 0, used, num_used, &num_found)) + 0, 0, used, num_used, &num_found)) return false; if (num_found != num_used) { diff --git a/ccan/tdb2/hash.c b/ccan/tdb2/hash.c index ae9442d9..d3a195a7 100644 --- a/ccan/tdb2/hash.c +++ b/ccan/tdb2/hash.c @@ -537,7 +537,7 @@ again: /* Return 1 if we find something, 0 if not, -1 on error. */ int next_in_hash(struct tdb_context *tdb, int ltype, struct traverse_info *tinfo, - TDB_DATA *kbuf, unsigned int *dlen) + TDB_DATA *kbuf, size_t *dlen) { const unsigned group_bits = TDB_TOPLEVEL_HASH_BITS-TDB_HASH_GROUP_BITS; tdb_off_t hlock_start, hlock_range, off; @@ -591,7 +591,7 @@ int next_in_hash(struct tdb_context *tdb, int ltype, /* Return 1 if we find something, 0 if not, -1 on error. */ int first_in_hash(struct tdb_context *tdb, int ltype, struct traverse_info *tinfo, - TDB_DATA *kbuf, unsigned int *dlen) + TDB_DATA *kbuf, size_t *dlen) { tinfo->prev = 0; tinfo->toplevel_group = 0; diff --git a/ccan/tdb2/io.c b/ccan/tdb2/io.c index 2bcee8a2..8f14d5b1 100644 --- a/ccan/tdb2/io.c +++ b/ccan/tdb2/io.c @@ -311,7 +311,8 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off, tdb->ecode = TDB_ERR_IO; tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv, "tdb_write failed at %llu len=%llu (%s)\n", - off, len, strerror(errno)); + (long long)off, (long long)len, + strerror(errno)); return -1; } } diff --git a/ccan/tdb2/private.h b/ccan/tdb2/private.h index c0377363..6c727aff 100644 --- a/ccan/tdb2/private.h +++ b/ccan/tdb2/private.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -60,10 +61,6 @@ typedef uint64_t tdb_len_t; typedef uint64_t tdb_off_t; -#ifndef offsetof -#define offsetof(t,f) ((unsigned int)&((t *)0)->f) -#endif - #define TDB_MAGIC_FOOD "TDB file\n" #define TDB_VERSION ((uint64_t)(0x26011967 + 7)) #define TDB_MAGIC ((uint64_t)0x1999)