From: Rolf Eike Beer Date: Tue, 22 Sep 2009 23:44:03 +0000 (-0700) Subject: Make sure the value in abs() does not get truncated if it is greater than 2^32 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a49c59c042c63b432307c1bbf7dac5a104c786e6;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git Make sure the value in abs() does not get truncated if it is greater than 2^32 abs() will truncate the input if is it outside the 2^32 range. Fix that by assuming `long' input. This might generate worse code in the common case. Signed-off-by: Rolf Eike Beer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 63dcaece1ac5..d3cd23f30039 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -146,7 +146,7 @@ extern int _cond_resched(void); #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) #define abs(x) ({ \ - int __x = (x); \ + long __x = (x); \ (__x < 0) ? -__x : __x; \ })