All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Tim Deegan <tim@xen.org>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
	Dario Faggioli <dario.faggioli@citrix.com>,
	Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] credit: track residual from divisions done during accounting
Date: Tue, 26 Feb 2013 12:00:19 +0000	[thread overview]
Message-ID: <512CA3D3.3040002@citrix.com> (raw)
In-Reply-To: <20130226115229.GB93966@ocelot.phlegethon.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 <george.dunlap@eu.citrix.com> wrote:
>>> On 02/25/2013 11:30 AM, Jan Beulich wrote:
>>>>>>> On 25.02.13 at 12:12, David Vrabel <david.vrabel@citrix.com> wrote:
>>>>> On 25/02/13 09:29, Jan Beulich wrote:
>>>>>>>>> On 22.02.13 at 18:26, Dario Faggioli <dario.faggioli@citrix.com> 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

  reply	other threads:[~2013-02-26 12:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 12:37 [PATCH] credit: track residual from divisions done during accounting Jan Beulich
2013-02-22 17:26 ` Dario Faggioli
2013-02-25  9:29   ` Jan Beulich
2013-02-25 10:45     ` Dario Faggioli
2013-02-25 11:12     ` David Vrabel
2013-02-25 11:30       ` Jan Beulich
2013-02-26 11:26         ` George Dunlap
2013-02-26 11:46           ` Jan Beulich
2013-02-26 11:52             ` Tim Deegan
2013-02-26 12:00               ` David Vrabel [this message]
2013-02-26 12:21                 ` Ian Campbell
2013-02-26 12:51                   ` Jan Beulich
2013-02-26 13:10                     ` Ian Campbell
2013-02-26 12:54                   ` George Dunlap
2013-02-26 13:46                     ` Tim Deegan
2013-02-26 15:00 ` George Dunlap
2013-02-26 15:07   ` Jan Beulich
2013-02-26 15:11     ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512CA3D3.3040002@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=dario.faggioli@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.