possible bug? OF_getprop() < sizeof()
Nathan Whitehorn
nwhitehorn at freebsd.org
Fri Jan 20 22:10:59 UTC 2012
On 01/20/12 15:38, Anders Gavare wrote:
> If I understood things correctly, there's a possible minor bug in
> ofw_machdep.c for PowerPC, in parse_ofw_memory:
>
> /*
> * Get #address-cells from root node, defaulting to 1 if it cannot
> * be found.
> */
> phandle = OF_finddevice("/");
> if (OF_getprop(phandle, "#address-cells",&address_cells,
> sizeof(address_cells))< sizeof(address_cells))
> address_cells = 1;
> if (OF_getprop(phandle, "#size-cells",&size_cells,
> sizeof(size_cells))< sizeof(size_cells))
> size_cells = 1;
>
> Running the code in GXemul, it seems that the comparison between
> OF_getprop's return value (-1 in case the property is not found) and the
> sizeof value is done as unsigned integers.
This does look like a bug. As you note, it doesn't come up often in real
life (the root OF node is actually required to have these properties by
the spec), but there may be other cases like this. Good catch!
-Nathan
More information about the freebsd-ppc
mailing list