dtc: Enable and fix -Wcast-qual warnings
authorDavid Gibson <david@gibson.dropbear.id.au>
Mon, 7 Jul 2008 00:14:15 +0000 (10:14 +1000)
committerGerald Van Baren <vanbaren@cideas.com>
Mon, 25 Aug 2008 02:20:49 +0000 (22:20 -0400)
Enabling -Wcast-qual warnings in dtc shows up a number of places where
we are incorrectly discarding a const qualification.  There are also
some places where we are intentionally discarding the 'const', and we
need an ugly cast through uintptr_t to suppress the warning.  However,
most of these are pretty well isolated with the *_w() functions.  So
in the interests of maximum safety with const qualifications, this
patch enables the warnings and fixes the existing complaints.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
include/libfdt.h
libfdt/fdt_ro.c
libfdt/fdt_rw.c
libfdt/libfdt_internal.h

index 2a2b23d6c196934e748f5baec78558328e854983..7e043ef759f0ddca198a319b1a6d063d3f8ab8e7 100644 (file)
 const void *fdt_offset_ptr(const void *fdt, int offset, int checklen);
 static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
 {
-       return (void *)fdt_offset_ptr(fdt, offset, checklen);
+       return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
 }
 
 uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
@@ -375,8 +375,8 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
                                                      const char *name,
                                                      int *lenp)
 {
-       return (struct fdt_property *)fdt_get_property(fdt, nodeoffset,
-                                                      name, lenp);
+       return (struct fdt_property *)(uintptr_t)
+               fdt_get_property(fdt, nodeoffset, name, lenp);
 }
 
 /**
@@ -411,7 +411,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
                                  const char *name, int *lenp)
 {
-       return (void *)fdt_getprop(fdt, nodeoffset, name, lenp);
+       return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
 }
 
 /**
index 8382afd38835c674702889caf0833815c55de38e..1c897c59138b3fa05fe4dfb89320fa1319723bc2 100644 (file)
@@ -81,7 +81,7 @@ static int nodename_eq(const void *fdt, int offset,
 
 const char *fdt_string(const void *fdt, int stroffset)
 {
-       return (char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
+       return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
 }
 
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
index 4a16014a9148ba92e9c6064757c73af884aa0a36..6837fb1edbc3ea4109e37fef995300171fc37df4 100644 (file)
@@ -261,7 +261,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
 
        RW_CHECK_HEADER(fdt);
 
-       namep = (char *)fdt_get_name(fdt, nodeoffset, &oldlen);
+       namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
        if (!namep)
                return oldlen;
 
@@ -436,7 +436,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
        /* But if that overlaps with the old tree... */
        if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
                /* Try right after the old tree instead */
-               tmp = (char *)fdtend;
+               tmp = (char *)(uintptr_t)fdtend;
                if ((tmp + newsize) > ((char *)buf + bufsize))
                        return -FDT_ERR_NOSPACE;
        }
index 2ba30dbe540547b71a75b58fe8536796626577c7..549e345391380419aa15d489fb7fe8679dac31b9 100644 (file)
@@ -77,19 +77,20 @@ static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
 
 static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
 {
-       return (void *)_fdt_offset_ptr(fdt, offset);
+       return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
 }
 
 static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
 {
-       const struct fdt_reserve_entry *rsv_table = (struct fdt_reserve_entry *)
+       const struct fdt_reserve_entry *rsv_table =
+               (const struct fdt_reserve_entry *)
                ((const char *)fdt + fdt_off_mem_rsvmap(fdt));
 
        return rsv_table + n;
 }
 static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
 {
-       return (void *)_fdt_mem_rsv(fdt, n);
+       return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
 }
 
 #define SW_MAGIC               (~FDT_MAGIC)