[Crosstoolchain-logs] [device-tree-compiler] 66/357: libfdt: Fixup usage of fdt_offset_ptr() in fdt_rw.c
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:05:51 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 568b569e8961641587cfda8ec23e64cafe45f6d7
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Tue Dec 12 15:46:14 2006 +1100
libfdt: Fixup usage of fdt_offset_ptr() in fdt_rw.c
Several places in fdt_rw.c incorrectly use fdt_offset_ptr(), using it
as if it returned an encoded error code on errors, instead of
returning NULL on error as it actually does.
In fact, however, in these instances the extra checks in
fdt_offset_ptr() are useless anyway, so we introduce a new (internal
use) _fdt_offset_ptr() and use that without checking.
(cherry picked from 3dffb1808dea6aee6158c92e17faa6ced9b183f2 commit)
---
fdt.c | 2 +-
fdt_rw.c | 19 +++++--------------
libfdt_internal.h | 5 +++++
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/fdt.c b/fdt.c
index 4271dfd..3b900a8 100644
--- a/fdt.c
+++ b/fdt.c
@@ -51,7 +51,7 @@ void *fdt_offset_ptr(const struct fdt_header *fdt, int offset, int len)
|| ((offset + len) > fdt_size_dt_struct(fdt)))
return NULL;
- p = (void *)fdt + fdt_off_dt_struct(fdt) + offset;
+ p = _fdt_offset_ptr(fdt, offset);
if (p + len < p)
return NULL;
diff --git a/fdt_rw.c b/fdt_rw.c
index 5cdb8c1..8049205 100644
--- a/fdt_rw.c
+++ b/fdt_rw.c
@@ -157,10 +157,7 @@ static struct fdt_property *_add_property(struct fdt_header *fdt, int nodeoffset
if (namestroff < 0)
return PTR_ERROR(-namestroff);
- prop = fdt_offset_ptr(fdt, nextoffset, 0);
- if ((err = fdt_ptr_error(prop)))
- return PTR_ERROR(err);
-
+ prop = _fdt_offset_ptr(fdt, nextoffset);
proplen = sizeof(*prop) + ALIGN(len, FDT_TAGSIZE);
err = _blob_splice_struct(fdt, prop, 0, proplen);
@@ -236,11 +233,9 @@ int fdt_add_subnode_namelen(struct fdt_header *fdt, int parentoffset,
tag = _fdt_next_tag(fdt, offset, &nextoffset);
} while (tag == FDT_PROP);
- nh = fdt_offset_ptr(fdt, offset, 0);
- if ((err = fdt_ptr_error(nh)))
- return OFFSET_ERROR(err);
-
+ nh = _fdt_offset_ptr(fdt, offset);
nodelen = sizeof(*nh) + ALIGN(namelen+1, FDT_TAGSIZE) + FDT_TAGSIZE;
+
err = _blob_splice_struct(fdt, nh, 0, nodelen);
if (err)
return OFFSET_ERROR(err);
@@ -261,7 +256,6 @@ int fdt_add_subnode(struct fdt_header *fdt, int parentoffset, const char *name)
int fdt_del_node(struct fdt_header *fdt, int nodeoffset)
{
- struct fdt_node_header *nh;
int endoffset;
int err;
@@ -269,11 +263,8 @@ int fdt_del_node(struct fdt_header *fdt, int nodeoffset)
if ((err = fdt_offset_error(endoffset)))
return err;
- nh = fdt_offset_ptr(fdt, nodeoffset, 0);
- if ((err = fdt_ptr_error(nh)))
- return err;
-
- return _blob_splice_struct(fdt, nh, endoffset - nodeoffset, 0);
+ return _blob_splice_struct(fdt, _fdt_offset_ptr(fdt, nodeoffset),
+ endoffset - nodeoffset, 0);
}
struct fdt_header *fdt_open_into(struct fdt_header *fdt, void *buf, int bufsize)
diff --git a/libfdt_internal.h b/libfdt_internal.h
index 8ea1ed0..d8c7551 100644
--- a/libfdt_internal.h
+++ b/libfdt_internal.h
@@ -31,6 +31,11 @@ uint32_t _fdt_next_tag(const struct fdt_header *fdt, int startoffset, int *nexto
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
int _fdt_node_end_offset(struct fdt_header *fdt, int nodeoffset);
+static inline void *_fdt_offset_ptr(const struct fdt_header *fdt, int offset)
+{
+ return (void *)fdt + fdt_off_dt_struct(fdt) + offset;
+}
+
#define OFFSET_ERROR(code) -(code)
#define PTR_ERROR(code) (void *)(-(long)(code))
--
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