diff options
author | Rolf Eike Beer <eike-kernel@sf-tec.de> | 2009-09-22 19:44:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-23 10:39:30 -0400 |
commit | a49c59c042c63b432307c1bbf7dac5a104c786e6 (patch) | |
tree | 443f9fab6d8907dec07a6c83fee2812c4bf43245 | |
parent | d7d7561c908afa001ab0fc8212eee94731a213a6 (diff) |
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 <eike-kernel@sf-tec.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/kernel.h | 2 |
1 files changed, 1 insertions, 1 deletions
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); | |||
146 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) | 146 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) |
147 | 147 | ||
148 | #define abs(x) ({ \ | 148 | #define abs(x) ({ \ |
149 | int __x = (x); \ | 149 | long __x = (x); \ |
150 | (__x < 0) ? -__x : __x; \ | 150 | (__x < 0) ? -__x : __x; \ |
151 | }) | 151 | }) |
152 | 152 | ||