All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Juran <jjuran@gmail.com>
To: Sverre Rabbelier <srabbelier@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	git@vger.kernel.org, Erik Faye-Lund <kusmabite@gmail.com>,
	Jeff King <peff@peff.net>, Nicolas Pitre <nico@fluxnic.net>,
	Pierre Habouzit <madcoder@debian.org>,
	Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Subject: Re: [PATCH] compat: helper for detecting unsigned overflow
Date: Thu, 10 Feb 2011 05:23:25 -0800	[thread overview]
Message-ID: <E84FF9D8-92D7-4CA0-9CF4-77FF33893977@gmail.com> (raw)
In-Reply-To: <AANLkTinqkSxj0C+GyMVR4a7d=yy_mh+oDuar0moZjZ8_@mail.gmail.com>

On Feb 10, 2011, at 4:11 AM, Sverre Rabbelier wrote:

> On Thu, Feb 10, 2011 at 10:35, Jonathan Nieder <jrnieder@gmail.com>  
> wrote:
>>       unsigned_add_overflows(a, b)
>
>> Define such a macro, expanding roughly to ((a) < UINT_MAX - (b)).
>> Because the expansion uses each argument only once outside of  
>> sizeof()
>> expressions, it is safe to use with arguments that have side effects.
>
>> +#define unsigned_add_overflows(a, b) \
>> +    ((b) > maximum_unsigned_value_of_type(a) - (a))
>
> I'm confused, you say you won't use it twice, and then you do use it  
> twice?

The author is asserting that maximum_unsigned_value_of_type() is a  
function of sizeof a, which would have no runtime effect.

Josh

      reply	other threads:[~2011-02-10 13:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05  7:24 [PATCH v4] do not depend on signed integer overflow Erik Faye-Lund
2010-10-05 13:28 ` Nicolas Pitre
2011-02-10  9:35 ` [PATCH] compat: helper for detecting unsigned overflow Jonathan Nieder
2011-02-10 12:11   ` Sverre Rabbelier
2011-02-10 13:23     ` Joshua Juran [this message]

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=E84FF9D8-92D7-4CA0-9CF4-77FF33893977@gmail.com \
    --to=jjuran@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ilari.liusvaara@elisanet.fi \
    --cc=jrnieder@gmail.com \
    --cc=kusmabite@gmail.com \
    --cc=madcoder@debian.org \
    --cc=nico@fluxnic.net \
    --cc=peff@peff.net \
    --cc=srabbelier@gmail.com \
    /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.