From owner-freebsd-ppc@FreeBSD.ORG Fri Jan 20 22:10:58 2012 Return-Path: Delivered-To: freebsd-ppc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5D7F106566B for ; Fri, 20 Jan 2012 22:10:58 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from argol.doit.wisc.edu (argol.doit.wisc.edu [144.92.197.212]) by mx1.freebsd.org (Postfix) with ESMTP id B92C58FC0C for ; Fri, 20 Jan 2012 22:10:58 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from avs-daemon.smtpauth3.wiscmail.wisc.edu by smtpauth3.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0LY400H02AY95I00@smtpauth3.wiscmail.wisc.edu> for freebsd-ppc@freebsd.org; Fri, 20 Jan 2012 16:10:57 -0600 (CST) Received: from wanderer.tachypleus.net (i3-user-nat.icecube.wisc.edu [128.104.255.12]) by smtpauth3.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0LY400FQ7AY85H00@smtpauth3.wiscmail.wisc.edu>; Fri, 20 Jan 2012 16:10:57 -0600 (CST) Date: Fri, 20 Jan 2012 16:10:56 -0600 From: Nathan Whitehorn In-reply-to: <1327095525.2825.10.camel@localhost.localdomain> To: anders@gavare.se Message-id: <4F19E670.1010006@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=128.104.255.12 X-Spam-PmxInfo: Server=avs-13, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.20.215714, SenderIP=128.104.255.12 References: <1327095525.2825.10.camel@localhost.localdomain> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111213 Thunderbird/8.0 Cc: freebsd-ppc@freebsd.org, Anders Gavare Subject: Re: possible bug? OF_getprop() < sizeof() X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jan 2012 22:10:59 -0000 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