summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2012-01-10 20:32:56 -0500
committerBryan Cantrill <bryan@joyent.com>2012-01-10 20:32:56 -0500
commit9ea7ddd89362f3fb046cc70bba7ee58c21bc5674 (patch)
tree67b3b22cd02d7c1d263454aeaab7ccdfd5856737
parentd7dba7e519e96f726807ca55f6a17fef3f90092f (diff)
downloadillumos-joyent-9ea7ddd89362f3fb046cc70bba7ee58c21bc5674.tar.gz
1920 ::ugrep and ::kgrep don't work for sizes less than 4
Reviewed by: Richard Lowe <richlowe@richlowe.net> Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/cmd/mdb/common/modules/genunix/kgrep.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr/src/cmd/mdb/common/modules/genunix/kgrep.c b/usr/src/cmd/mdb/common/modules/genunix/kgrep.c
index c0eab1aec1..7052827562 100644
--- a/usr/src/cmd/mdb/common/modules/genunix/kgrep.c
+++ b/usr/src/cmd/mdb/common/modules/genunix/kgrep.c
@@ -23,7 +23,9 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2011 Joyent, Inc. All rights reserved.
+ */
/*
* Generic memory walker, used by both the genunix and libumem dmods.
@@ -154,8 +156,14 @@ kgrep_range_fancybits(uintptr_t base, uintptr_t lim, void *kg_arg) \
for (pos = page; pos < page_end; pos++) { \
cur = *pos; \
\
+ /* \
+ * Due to C's (surprising) integral promotion \
+ * rules for unsigned types smaller than an \
+ * int, we need to explicitly cast the result \
+ * of cur minus pattern, below. \
+ */ \
if (((cur ^ pattern) & mask) != 0 && \
- (cur - pattern) >= dist) \
+ (uintbits_t)(cur - pattern) >= dist) \
continue; \
\
out = cur; \