Thread (5 messages) flat view 5 messages, 5 authors, 2016-06-15

Re: [PATCH] compat: helper for detecting unsigned overflow

From: Sverre Rabbelier <hidden>
Date: 2016-06-15 22:50:32

Heya,

On Thu, Feb 10, 2011 at 10:35, Jonathan Nieder [off-list ref] 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?

-- 
Cheers,

Sverre Rabbelier
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help