From: "Jan Beulich" Subject: Re: [PATCH] fix misc issues related toallowingsupport of more CPUs Date: Mon, 22 Sep 2008 15:57:01 +0100 Message-ID: <48D7CE5D.76E4.0078.0@novell.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >>> Keir Fraser 22.09.08 16:02 >>> >On 22/9/08 09:35, "Keir Fraser" wrote: > >> On 22/9/08 08:46, "Jan Beulich" wrote: >>=20 >>>> Why must it be WARN_ON()? You think you could specify strings so long = that >>>> they overflow 32 bits? You've got other problems in that case. >>>=20 >>> No, that's not the reason. It's because of how bitmap_scnprintf() and >>> bitmap_scnlistprintf() work - they can (validly, assuming that the = code >>> having been derived from Linux and still being that way in Linux, = hence >>> apparently considered correct) pass negative sizes to scnprintf(), and >>> hence it must not kill the system to actually do so. >>=20 >> The obvious answer would be to fix the bogus callers. Or consider = negative >> size to be a valid input. Warning on what callers consider valid = behaviour >> is just weird. I would say the former (fix the callers) is the better = way to >> go here; presumably they just need to clamp the size parameter. > >Further to this, actually I think the callers in bitmap.c are correct. >Assuming len<=3Dbuflen at the start of the bitmap_scn*() functions (valid >since buflen is non-negative and len =3D=3D 0 at function start) then = we'll >never have len>buflen because scnprintf() truncates its return value to = be >less than its size parameter, which is always buflen-len. Ah, right - while I looked at this difference to snprintf(), I then forgot = about it again. Thanks for spotting and clarifying, Jan