From 9ea7ddd89362f3fb046cc70bba7ee58c21bc5674 Mon Sep 17 00:00:00 2001 From: Bryan Cantrill Date: Tue, 10 Jan 2012 20:32:56 -0500 Subject: 1920 ::ugrep and ::kgrep don't work for sizes less than 4 Reviewed by: Richard Lowe Reviewed by: Robert Mustacchi Approved by: Richard Lowe --- usr/src/cmd/mdb/common/modules/genunix/kgrep.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'usr/src') 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; \ -- cgit v1.2.3