tdb2: fix warnings with -Wcast-qual using ccan/cast.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 21 Mar 2011 11:34:30 +0000 (22:04 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 21 Mar 2011 11:34:30 +0000 (22:04 +1030)
ccan/tdb2/_info
ccan/tdb2/io.c
ccan/tdb2/open.c
ccan/tdb2/private.h

index 0e894e5b3ad0bba51ef08979bfd4d41e982bc7eb..b1fc56d5622668638e2a03043de240a53d035130 100644 (file)
@@ -86,6 +86,7 @@ int main(int argc, char *argv[])
                printf("ccan/failtest\n");
                printf("ccan/tally\n");
                printf("ccan/typesafe_cb\n");
+               printf("ccan/cast\n");
                return 0;
        }
 
index 0e27e1d0faea07a2d8640e46db187a0298afcfb8..4ed37ca2cffbeaac1c6398ac5dbf20926e6d0d83 100644 (file)
@@ -439,7 +439,7 @@ static enum TDB_ERROR tdb_expand_file(struct tdb_context *tdb,
 const void *tdb_access_read(struct tdb_context *tdb,
                            tdb_off_t off, tdb_len_t len, bool convert)
 {
-       const void *ret = NULL;
+       void *ret = NULL;
 
        if (likely(!(tdb->flags & TDB_CONVERT))) {
                ret = tdb->methods->direct(tdb, off, len, false);
index 9aaa218a29c03153e26db7c774a81389bac2c3aa..f7d6b3c5f3e5dbe356d9b842fcb1c30c36e93800 100644 (file)
@@ -454,7 +454,7 @@ fail_errno:
 #ifdef TDB_TRACE
        close(tdb->tracefd);
 #endif
-       free((char *)tdb->name);
+       free(cast_const(char *, tdb->name));
        if (tdb->file) {
                tdb_unlock_all(tdb);
                if (--tdb->file->refcnt == 0) {
@@ -495,7 +495,7 @@ int tdb_close(struct tdb_context *tdb)
                else
                        tdb_munmap(tdb->file);
        }
-       free((char *)tdb->name);
+       free(cast_const(char *, tdb->name));
        if (tdb->file) {
                struct tdb_file **i;
 
index 63354a43dd829c52f82d0a933783f6c67ce8782b..1e31ec159fbe457cfd570cdf60d6461d62e52dfa 100644 (file)
@@ -35,6 +35,7 @@
 #include <ccan/tdb2/tdb2.h>
 #include <ccan/likely/likely.h>
 #include <ccan/compiler/compiler.h>
+#include <ccan/cast/cast.h>
 #if HAVE_BYTESWAP_H
 #include <byteswap.h>
 #endif
@@ -75,7 +76,7 @@ typedef uint64_t tdb_off_t;
 
 /* Packing errors into pointers and v.v. */
 #define TDB_PTR_IS_ERR(ptr) \
-       unlikely((void *)(ptr) >= (void *)(long)TDB_ERR_LAST)
+       unlikely((unsigned long)(ptr) >= (unsigned long)TDB_ERR_LAST)
 #define TDB_PTR_ERR(p) ((enum TDB_ERROR)(long)(p))
 #define TDB_ERR_PTR(err) ((void *)(long)(err))