libfdt: Abolish encoding of error codes into pointers
This patch abolishes the non-standard and confusing encoding of errors
into pointer return values. The only functions still returning such a
potentially encoded pointer are fdt_get_property() and fdt_getprop().
Those functions also return a length via an (int *). With this patch
those functions instead now return NULL on any error, and return the
code indicating the type of error in the length paramater.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
diff --git a/fdt_wip.c b/fdt_wip.c
index d353377..88b9ba2 100644
--- a/fdt_wip.c
+++ b/fdt_wip.c
@@ -28,11 +28,10 @@
{
void *propval;
int proplen;
- int err;
propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
- if ((err = fdt_ptr_error(propval)))
- return err;
+ if (! propval)
+ return -proplen;
if (proplen != len)
return FDT_ERR_SIZE_MISMATCH;
@@ -53,11 +52,10 @@
{
struct fdt_property *prop;
int len;
- int err;
prop = fdt_get_property(fdt, nodeoffset, name, &len);
- if ((err = fdt_ptr_error(prop)))
- return err;
+ if (! prop)
+ return -len;
nop_region(prop, len + sizeof(*prop));