[Crosstoolchain-logs] [device-tree-compiler] 50/357: Simplify string table access functions

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:05:47 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 3aa4cfd66bf75b67a2ddaed8454d0483762e69ba
Author: David Gibson <dgibson at sneetch.(none)>
Date:   Wed Nov 29 16:34:30 2006 +1100

    Simplify string table access functions
    
    The range sanity checking on the fdt_string_cmp() function causes problems
    for the sequential write code (or at least for using RO functions on an
    incomplete SW tree).  Plus they didn't really fit with the philosphy for
    the RO code of working as widely as possible on weirdly constructed trees.
---
 fdt.c    | 20 --------------------
 fdt_ro.c |  7 ++++++-
 libfdt.h |  3 +--
 3 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/fdt.c b/fdt.c
index 0de7f68..03f1a0d 100644
--- a/fdt.c
+++ b/fdt.c
@@ -34,26 +34,6 @@ void *fdt_offset_ptr(const struct fdt_header *fdt, int offset, int len)
 	return p;
 }
 
-char *fdt_string(const struct fdt_header *fdt, int stroffset)
-{
-	return (char *)fdt + fdt32_to_cpu(fdt->off_dt_strings) + stroffset;
-}
-
-int fdt_string_cmp(const struct fdt_header *fdt, int stroffset, const char *s2)
-{
-	const char *s1 = fdt_string(fdt, stroffset);
-	int len = strlen(s2) + 1;
-
-	if (! s1)
-		return 0;
-
-	if ((stroffset + len < stroffset)
-	    || (stroffset + len > fdt32_to_cpu(fdt->size_dt_strings)))
-		return -2;
-
-	return strcmp(s1, s2);
-}
-
 uint32_t _fdt_next_tag(const struct fdt_header *fdt, int offset, int *nextoffset)
 {
 	const uint32_t *tagp, *lenp;
diff --git a/fdt_ro.c b/fdt_ro.c
index c2a0e72..bfd8163 100644
--- a/fdt_ro.c
+++ b/fdt_ro.c
@@ -59,6 +59,11 @@ static int offset_streq(const struct fdt_header *fdt, int offset,
 	return 1;
 }
 
+char *fdt_string(const struct fdt_header *fdt, int stroffset)
+{
+	return (char *)fdt + fdt32_to_cpu(fdt->off_dt_strings) + stroffset;
+}
+
 int fdt_property_offset(const struct fdt_header *fdt, int nodeoffset,
 			const char *name)
 {
@@ -103,7 +108,7 @@ int fdt_property_offset(const struct fdt_header *fdt, int nodeoffset,
 			if (! prop)
 				return OFFSET_ERROR(FDT_ERR_BADSTRUCTURE);
 			namestroff = fdt32_to_cpu(prop->nameoff);
-			if (fdt_string_cmp(fdt, namestroff, name) == 0)
+			if (streq(fdt_string(fdt, namestroff), name))
 				/* Found it! */
 				return offset;
 			break;
diff --git a/libfdt.h b/libfdt.h
index 7f279a6..605aa89 100644
--- a/libfdt.h
+++ b/libfdt.h
@@ -54,10 +54,9 @@ void *fdt_offset_ptr(const struct fdt_header *fdt, int offset, int checklen);
 #define fdt_ptr_error(ptr) \
 	( (((long)(ptr) < 0) && ((long)(ptr) >= -FDT_ERR_MAX)) ? -(long)(ptr) : 0 )
 
+/* Read-only functions */
 char *fdt_string(const struct fdt_header *fdt, int stroffset);
-int fdt_string_cmp(const struct fdt_header *fdt, int stroffset, const char *s2);
 
-/* Read-only functions */
 int fdt_property_offset(const struct fdt_header *fdt, int nodeoffset,
 			const char *name);
 int fdt_subnode_offset_namelen(const struct fdt_header *fdt, int parentoffset,

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