From 1c0c0dee6b06dc1b3dfbf19e2a05bcd2ad7751c9 Mon Sep 17 00:00:00 2001 From: des Date: Sun, 15 Aug 2010 14:55:32 +0000 Subject: no-op commit to note that the example given in the previous commit is a very bad one, since the shift does not actually overflow. This is a better example (assuming uint64_t = unsigned long long): ~0LLU >> 9 = 0x7fffffffffffffLLU ~0LLU >> 9 << 10 = 0xfffffffffffffc00LLU ~0LLU >> 9 << 10 >> 10 = 0x3fffffffffffffLLU --- lib/libutil/expand_number.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libutil') diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c index 9bb0308..30a292e 100644 --- a/lib/libutil/expand_number.c +++ b/lib/libutil/expand_number.c @@ -66,7 +66,7 @@ expand_number(const char *buf, uint64_t *num) return (0); } -#define SHIFT(n, b) \ +#define SHIFT(n, b) \ do { if (((n << b) >> b) != n) goto overflow; n <<= b; } while (0) switch (tolower((unsigned char)*endptr)) { -- cgit v1.1