aboutsummaryrefslogtreecommitdiff
path: root/lib/libutil/expand_number.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2010-08-15 14:55:32 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2010-08-15 14:55:32 +0000
commitb6fbd4d50dd30e90231bb0b2f8ddf9fd96691b39 (patch)
tree2df0914821a027f90d0fb465de23796faf70a3c0 /lib/libutil/expand_number.c
parent1035d74025de93515f0a7baf2c48eed25e854099 (diff)
downloadsrc-b6fbd4d50dd30e90231bb0b2f8ddf9fd96691b39.tar.gz
src-b6fbd4d50dd30e90231bb0b2f8ddf9fd96691b39.zip
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
Notes
Notes: svn path=/head/; revision=211338
Diffstat (limited to 'lib/libutil/expand_number.c')
-rw-r--r--lib/libutil/expand_number.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c
index 9bb0308d1415..30a292ef64c2 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)) {