Date: Sun, 15 Aug 2010 14:55:32 +0000 (UTC) From: Dag-Erling Smorgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r211338 - head/lib/libutil Message-ID: <201008151455.o7FEtW75063515@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Sun Aug 15 14:55:32 2010 New Revision: 211338 URL: http://svn.freebsd.org/changeset/base/211338 Log: 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 Modified: head/lib/libutil/expand_number.c Modified: head/lib/libutil/expand_number.c ============================================================================== --- head/lib/libutil/expand_number.c Sun Aug 15 14:50:03 2010 (r211337) +++ head/lib/libutil/expand_number.c Sun Aug 15 14:55:32 2010 (r211338) @@ -66,7 +66,7 @@ expand_number(const char *buf, uint64_t 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)) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008151455.o7FEtW75063515>