From: Joshua Juran Date: Thu, 10 Feb 2011 13:23:25 GMT Subject: Re: [PATCH] compat: helper for detecting unsigned overflow Message-ID: In-Reply-To: On Feb 10, 2011, at 4:11 AM, Sverre Rabbelier wrote: > On Thu, Feb 10, 2011 at 10:35, Jonathan Nieder > 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