From: "Jan Beulich" Subject: Re: [PATCH] xen: clamp bitmaps to correct number of bits Date: Thu, 06 Sep 2012 15:47:25 +0100 Message-ID: <5048D39D0200007800099684@nat28.tlf.novell.com> References: <22d5e100131d1576d455.1346932605@cosworth.uk.xensource.com> <5048B1C4020000780009952E@nat28.tlf.novell.com> <1346939323.30018.12.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1346939323.30018.12.camel@zakaz.uk.xensource.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: "Tim (Xen.org)" , Dario Faggioli , "Keir (Xen.org)" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org >>> On 06.09.12 at 15:48, Ian Campbell wrote: > On Thu, 2012-09-06 at 13:23 +0100, Jan Beulich wrote: >> >>> On 06.09.12 at 13:56, Ian Campbell wrote: >> > +/* Ensure that the last byte is zero from nbits onwards. */ >> > +static void clamp_last_byte(uint8_t *bp, int nbits) >> > +{ >> > + int lastbyte = nbits/8; >> > + int remainder = nbits % 8; >> > + int mask = ((1U<> >> While I realize the callers use plain int, I'd be very much in favor >> of not continuing this bad practice (the more that you use 1U >> already) - simply make the parameter and all locals (assuming >> you really think they're useful; I would have omitted all but >> "remainder", given they're being used just once) unsigned. > > I'll fold them in, it was convenient to have variables while I was > printk'ing what I was doing but not any more. I won't ask you for another round because of this, but you still left the parameter and remaining local variable as plain int, nor did you insert whitespace into the expressions. If I were the one to commit this, I would do the adjustment while committing... Anyway, as long as there's no easily visible tools side bug addressed by this, I would think we should rather leave this for after branching - Keir? Jan