Date: Fri, 20 Jan 2012 16:10:56 -0600 From: Nathan Whitehorn <nwhitehorn@freebsd.org> To: anders@gavare.se Cc: freebsd-ppc@freebsd.org, Anders Gavare <gavare@gmail.com> Subject: Re: possible bug? OF_getprop() < sizeof() Message-ID: <4F19E670.1010006@freebsd.org> In-Reply-To: <1327095525.2825.10.camel@localhost.localdomain> References: <1327095525.2825.10.camel@localhost.localdomain>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F19E670.1010006>