[Crosstoolchain-logs] [device-tree-compiler] 81/357: libfdt: Fix fdt_strerror() bugs
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:05:52 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 5434fcc7e05e86b61530999d48548e6f18036cf7
Author: David Gibson <dgibson at sneetch.(none)>
Date: Fri Feb 23 14:40:10 2007 +1100
libfdt: Fix fdt_strerror() bugs
This fixes several small bugs related to fdt_strerror().
- an entry is added to the error table for FDT_ERR_BADLAYOUT.
- Incorrect usage of fdt_strerror() in check_property() and
check_getprop() is corrected (they were passing a positive error code,
when fdt_strerror() expects a negative code).
- Add code to properly retreive an error code from
fdt_get_property() in check_property(). With that a check that the
length returned by fdt_get_property() matches that stored in the
retreived property.
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
fdt_strerror.c | 3 ++-
tests/testutils.c | 12 +++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/fdt_strerror.c b/fdt_strerror.c
index 74c97e7..7f231ce 100644
--- a/fdt_strerror.c
+++ b/fdt_strerror.c
@@ -43,13 +43,14 @@ static struct errtabent errtable[] = {
ERRTABENT(FDT_ERR_BADMAGIC),
ERRTABENT(FDT_ERR_BADVERSION),
ERRTABENT(FDT_ERR_BADSTRUCTURE),
+ ERRTABENT(FDT_ERR_BADLAYOUT),
};
#define ERRTABSIZE (sizeof(errtable) / sizeof(errtable[0]))
const char *fdt_strerror(int errval)
{
if (errval > 0)
- return "<valid offset>";
+ return "<valid offset/length>";
else if (errval == 0)
return "<no error>";
else if (errval > -ERRTABSIZE) {
diff --git a/tests/testutils.c b/tests/testutils.c
index 9637415..c7b4b9e 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -72,14 +72,16 @@ void check_property(void *fdt, int nodeoffset, const char *name,
int len, const void *val)
{
const struct fdt_property *prop;
+ int retlen;
uint32_t tag, nameoff, proplen;
const char *propname;
verbose_printf("Checking property \"%s\"...", name);
- prop = fdt_get_property(fdt, nodeoffset, name, NULL);
+ prop = fdt_get_property(fdt, nodeoffset, name, &retlen);
verbose_printf("pointer %p\n", prop);
if (! prop)
- FAIL("NULL retreiving \"%s\" pointer", name);
+ FAIL("Error retreiving \"%s\" pointer: %s", name,
+ fdt_strerror(retlen));
tag = fdt32_to_cpu(prop->tag);
nameoff = fdt32_to_cpu(prop->nameoff);
@@ -92,6 +94,10 @@ void check_property(void *fdt, int nodeoffset, const char *name,
if (!propname || !streq(propname, name))
FAIL("Property name mismatch \"%s\" instead of \"%s\"",
propname, name);
+ if (proplen != retlen)
+ FAIL("Length retrieved for \"%s\" by fdt_get_property()"
+ " differs from stored length (%d != %d)",
+ name, retlen, proplen);
if (proplen != len)
FAIL("Size mismatch on property \"%s\": %d insead of %d",
name, proplen, len);
@@ -108,7 +114,7 @@ void *check_getprop(void *fdt, int nodeoffset, const char *name,
propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
if (! propval)
- FAIL("fdt_getprop(\"%s\"): %s", name, fdt_strerror(-proplen));
+ FAIL("fdt_getprop(\"%s\"): %s", name, fdt_strerror(proplen));
if (proplen != len)
FAIL("Size mismatch on property \"%s\": %d insead of %d",
--
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