[Crosstoolchain-logs] [device-tree-compiler] 195/357: libfdt: Abolish fdt_offset_ptr_typed()

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:06:13 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 2cf86939aff2692098396e7f25ce299e7195fa12
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Mon Nov 19 17:26:22 2007 +1100

    libfdt: Abolish fdt_offset_ptr_typed()
    
    The fdt_offset_ptr_typed() macro seemed like a good idea at the time.
    However, it's not actually used all that often, it can silently throw
    away const qualifications and it uses a gcc extension (typeof) which
    I'd prefer to avoid for portability.
    
    Therefore, this patch gets rid of it (and the fdt_offset_ptr_typed_w()
    variant which was never used at all).  It also makes a few variables
    const in testcases, which always should have been const, but weren't
    caught before because of the aforementioned silent discards.
    
    Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 libfdt/fdt_ro.c            | 2 +-
 libfdt/libfdt.h            | 6 ------
 tests/dtbs_equal_ordered.c | 4 ++--
 tests/path_offset.c        | 4 ++--
 tests/root_node.c          | 4 ++--
 tests/subnode_offset.c     | 4 ++--
 6 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index ef082be..12a37d5 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -249,7 +249,7 @@ const struct fdt_property *fdt_get_property(const void *fdt,
 
 		case FDT_PROP:
 			err = -FDT_ERR_BADSTRUCTURE;
-			prop = fdt_offset_ptr_typed(fdt, offset, prop);
+			prop = fdt_offset_ptr(fdt, offset, sizeof(*prop));
 			if (! prop)
 				goto fail;
 			namestroff = fdt32_to_cpu(prop->nameoff);
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index a61e50d..6b2fb92 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -128,12 +128,6 @@ static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
 	return (void *)fdt_offset_ptr(fdt, offset, checklen);
 }
 
-
-#define fdt_offset_ptr_typed(fdt, offset, var) \
-	((typeof(var))(fdt_offset_ptr((fdt), (offset), sizeof(*(var)))))
-#define fdt_offset_ptr_typed_w(fdt, offset, var) \
-	((typeof(var))(fdt_offset_ptr_w((fdt), (offset), sizeof(*(var)))))
-
 uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
 
 /**********************************************************************/
diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c
index d72124f..0c30ad3 100644
--- a/tests/dtbs_equal_ordered.c
+++ b/tests/dtbs_equal_ordered.c
@@ -93,10 +93,10 @@ void compare_structure(const void *fdt1, const void *fdt2)
 			break;
 
 		case FDT_PROP:
-			prop1 = fdt_offset_ptr_typed(fdt1, offset1, prop1);
+			prop1 = fdt_offset_ptr(fdt1, offset1, sizeof(*prop1));
 			if (!prop1)
 				FAIL("Could get fdt1 property at %d", offset1);
-			prop2 = fdt_offset_ptr_typed(fdt2, offset2, prop2);
+			prop2 = fdt_offset_ptr(fdt2, offset2, sizeof(*prop2));
 			if (!prop2)
 				FAIL("Could get fdt2 property at %d", offset2);
 
diff --git a/tests/path_offset.c b/tests/path_offset.c
index 834bc93..4b014ac 100644
--- a/tests/path_offset.c
+++ b/tests/path_offset.c
@@ -31,7 +31,7 @@
 int check_subnode(void *fdt, int parent, const char *name)
 {
 	int offset;
-	struct fdt_node_header *nh;
+	const struct fdt_node_header *nh;
 	uint32_t tag;
 
 	verbose_printf("Checking subnode \"%s\" of %d...", name, parent);
@@ -39,7 +39,7 @@ int check_subnode(void *fdt, int parent, const char *name)
 	verbose_printf("offset %d...", offset);
 	if (offset < 0)
 		FAIL("fdt_subnode_offset(\"%s\"): %s", name, fdt_strerror(offset));
-	nh = fdt_offset_ptr_typed(fdt, offset, nh);
+	nh = fdt_offset_ptr(fdt, offset, sizeof(*nh));
 	verbose_printf("pointer %p\n", nh);
 	if (! nh)
 		FAIL("NULL retrieving subnode \"%s\"", name);
diff --git a/tests/root_node.c b/tests/root_node.c
index fa2dc90..3f47829 100644
--- a/tests/root_node.c
+++ b/tests/root_node.c
@@ -32,12 +32,12 @@
 int main(int argc, char *argv[])
 {
 	void *fdt;
-	struct fdt_node_header *nh;
+	const struct fdt_node_header *nh;
 
 	test_init(argc, argv);
 	fdt = load_blob_arg(argc, argv);
 
-	nh = fdt_offset_ptr_typed(fdt, 0, nh);
+	nh = fdt_offset_ptr(fdt, 0, sizeof(*nh));
 
 	if (! nh)
 		FAIL("NULL retrieving root node");
diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c
index f5b88e1..ac2f32e 100644
--- a/tests/subnode_offset.c
+++ b/tests/subnode_offset.c
@@ -31,7 +31,7 @@
 int check_subnode(struct fdt_header *fdt, int parent, const char *name)
 {
 	int offset;
-	struct fdt_node_header *nh;
+	const struct fdt_node_header *nh;
 	uint32_t tag;
 
 	verbose_printf("Checking subnode \"%s\" of %d...", name, parent);
@@ -39,7 +39,7 @@ int check_subnode(struct fdt_header *fdt, int parent, const char *name)
 	verbose_printf("offset %d...", offset);
 	if (offset < 0)
 		FAIL("fdt_subnode_offset(\"%s\"): %s", name, fdt_strerror(offset));
-	nh = fdt_offset_ptr_typed(fdt, offset, nh);
+	nh = fdt_offset_ptr(fdt, offset, sizeof(*nh));
 	verbose_printf("pointer %p\n", nh);
 	if (! nh)
 		FAIL("NULL retrieving subnode \"%s\"", name);

-- 
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