[Crosstoolchain-logs] [device-tree-compiler] 287/357: dtc: Enable and fix -Wcast-qual warnings
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:06:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
zumbi pushed a commit to branch upstream/1.3.x
in repository device-tree-compiler.
commit 1409097db8be6ba662e3808654671554c5803bf0
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Mon Jul 7 10:14:15 2008 +1000
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 <david at gibson.dropbear.id.au>
---
Makefile | 2 +-
ftdump.c | 4 ++--
libfdt/fdt_ro.c | 2 +-
libfdt/fdt_rw.c | 4 ++--
libfdt/libfdt.h | 8 ++++----
libfdt/libfdt_internal.h | 7 ++++---
treesource.c | 2 +-
7 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/Makefile b/Makefile
index c20fc9e..0fa27b2 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ LOCAL_VERSION =
CONFIG_LOCALVERSION =
CPPFLAGS = -I libfdt
-CFLAGS = -Wall -g -Os -Wpointer-arith
+CFLAGS = -Wall -g -Os -Wpointer-arith -Wcast-qual
BISON = bison
LEX = flex
diff --git a/ftdump.c b/ftdump.c
index 1f94a05..01e61a4 100644
--- a/ftdump.c
+++ b/ftdump.c
@@ -48,11 +48,11 @@ static void print_data(const void *data, int len)
return;
if (is_printable_string(data, len)) {
- printf(" = \"%s\"", (char *)data);
+ printf(" = \"%s\"", (const char *)data);
} else if ((len % 4) == 0) {
printf(" = <");
for (i = 0; i < len; i += 4)
- printf("%08x%s", *((uint32_t *)data + i),
+ printf("%08x%s", *((const uint32_t *)data + i),
i < (len - 4) ? " " : "");
printf(">");
} else {
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 2a6e905..5ce5ccf 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -77,7 +77,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 0284a4f..eef32b9 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -257,7 +257,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;
@@ -432,7 +432,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.h b/libfdt/libfdt.h
index 8645de0..ad58a84 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -125,7 +125,7 @@
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);
}
/**
diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
index 2ba30db..549e345 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)
diff --git a/treesource.c b/treesource.c
index c32e818..ebeb6eb 100644
--- a/treesource.c
+++ b/treesource.c
@@ -176,7 +176,7 @@ static void write_propval_bytes(FILE *f, struct data val)
}
fprintf(f, "%02hhx", *bp++);
- if ((void *)bp >= propend)
+ if ((const void *)bp >= propend)
break;
fprintf(f, " ");
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git
More information about the Crosstoolchain-logs
mailing list