From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCH] credit: track residual from divisions done during accounting Date: Tue, 26 Feb 2013 12:00:19 +0000 Message-ID: <512CA3D3.3040002@citrix.com> References: <51222E8302000078000BF1F3@nat28.tlf.novell.com> <1361554003.16232.33.camel@Solace> <512B3CF702000078000C0AC6@nat28.tlf.novell.com> <512B4724.5000603@citrix.com> <512B594E02000078000C0BD1@nat28.tlf.novell.com> <512C9BD2.70903@eu.citrix.com> <512CAEA902000078000C10BF@nat28.tlf.novell.com> <20130226115229.GB93966@ocelot.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130226115229.GB93966@ocelot.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tim Deegan Cc: George Dunlap , Dario Faggioli , Jan Beulich , xen-devel List-Id: xen-devel@lists.xenproject.org On 26/02/13 11:52, Tim Deegan wrote: > At 11:46 +0000 on 26 Feb (1361879193), Jan Beulich wrote: >>>>> On 26.02.13 at 12:26, George Dunlap wrote: >>> On 02/25/2013 11:30 AM, Jan Beulich wrote: >>>>>>> On 25.02.13 at 12:12, David Vrabel wrote: >>>>> On 25/02/13 09:29, Jan Beulich wrote: >>>>>>>>> On 22.02.13 at 18:26, Dario Faggioli wrote: >>>>>>> On Mon, 2013-02-18 at 12:37 +0000, Jan Beulich wrote: >>>>>>>> + ASSERT(credits == val); >>>>>>> >>>>>>> I may be missing something, but how can the assert ever be false, given >>>>>>> the assignment right before it? >>>>>> >>>>>> val being wider than credit, this checks that there was no truncation. >>>>> >>>>> ASSERT(val <= UINT_MAX); >>>>> >>>>> Would be clearer. >>>> >>>> A matter of taste perhaps... >>> >>> I have a taste for coders having to keep as little state in their head >>> as possible. :-) Comparing to UINT_MAX prompts the coder specifically >>> to think about the size of the variables. >> >> Okay, assuming this is the only thing you dislike, I'll change it then >> and re-submit. >> >> But for the record - using UINT_MAX here will get things out of >> sync the moment the type of "credits" changes, whereas with >> the way I had coded it this would be taken care of implicitly. > > How about ASSERT(((typeof credits) val) == val) before the assignment? FWIW, this works for me. David