Mercurial > illumos > illumos-gate
changeset 13558:4fab5e00a936
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>
author | Bryan Cantrill <bryan@joyent.com> |
---|---|
date | Tue, 10 Jan 2012 20:32:56 -0500 |
parents | 36d116935c7e |
children | 8413443ef603 |
files | usr/src/cmd/mdb/common/modules/genunix/kgrep.c |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/mdb/common/modules/genunix/kgrep.c Tue Jan 10 20:31:45 2012 -0500 +++ b/usr/src/cmd/mdb/common/modules/genunix/kgrep.c Tue Jan 10 20:32:56 2012 -0500 @@ -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 @@ 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; \