Browse Source

tdb2: 64 bit fixes.

Rusty Russell 15 years ago
parent
commit
3d10865d15
4 changed files with 9 additions and 10 deletions
  1. 4 3
      ccan/tdb2/check.c
  2. 2 2
      ccan/tdb2/hash.c
  3. 2 1
      ccan/tdb2/io.c
  4. 1 4
      ccan/tdb2/private.h

+ 4 - 3
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) {

+ 2 - 2
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;

+ 2 - 1
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;
 		}
 	}

+ 1 - 4
ccan/tdb2/private.h

@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <sys/time.h>
 #include <sys/mman.h>
 #include <unistd.h>
@@ -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)