]> git.ozlabs.org Git - ccan/commitdiff
tdb2: 64 bit fixes.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Oct 2010 03:49:11 +0000 (14:19 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Oct 2010 03:49:11 +0000 (14:19 +1030)
ccan/tdb2/check.c
ccan/tdb2/hash.c
ccan/tdb2/io.c
ccan/tdb2/private.h

index c2ca95d08bcddfa98444d3d1354987c8168ce19a..eb8ddcae79baba5ba8f0fa8a5b4e908b4332f105 100644 (file)
@@ -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) {
index ae9442d934d149717cd13200bea98b8424466cfa..d3a195a789f5fcdd76a957e8069e03d2eb0176e3 100644 (file)
@@ -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;
index 2bcee8a29a17665edf3a08a6b6264bdb7c446322..8f14d5b12e37563d101084e222c08d15b3fc0a4f 100644 (file)
@@ -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;
                }
        }
index c0377363c6ac14a705868f5c74beca86f213ff84..6c727aff4a20a62dc800e5806079742cd32d7ec1 100644 (file)
@@ -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>
 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)