From c66830263af19831f2b7db307f79d1943febf7f9 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 7 Jul 2008 10:14:15 +1000 Subject: dtc: Enable and fix -Wcast-qual warnings 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 Acked-by: Gerald Van Baren --- libfdt/fdt_ro.c | 2 +- libfdt/fdt_rw.c | 4 ++-- libfdt/libfdt_internal.h | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'libfdt') diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index 8382afd388..1c897c5913 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -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) diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c index 4a16014a91..6837fb1edb 100644 --- a/libfdt/fdt_rw.c +++ b/libfdt/fdt_rw.c @@ -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; } diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h index 2ba30dbe54..549e345391 100644 --- a/libfdt/libfdt_internal.h +++ b/libfdt/libfdt_internal.h @@ -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) -- cgit v1.2.1