Fix an issue with ktrdump(8) where it would not print all entries in the
KTR buffer. This happens when 'i' tries to wrap around from 0 to 'entries - 1'. Since 'i' is a signed integer the modulo operation actually returns a negative number. Fix this by computing the next index to use "by hand" instead of relying on the modulo operator.
This commit is contained in:
parent
65d07b6871
commit
f8c8b7ee8f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=263194
@ -219,8 +219,11 @@ main(int ac, char **av)
|
|||||||
/*
|
/*
|
||||||
* Now tear through the trace buffer.
|
* Now tear through the trace buffer.
|
||||||
*/
|
*/
|
||||||
if (!iflag)
|
if (!iflag) {
|
||||||
i = (index - 1) % entries;
|
i = index - 1;
|
||||||
|
if (i < 0)
|
||||||
|
i = entries - 1;
|
||||||
|
}
|
||||||
tlast = -1;
|
tlast = -1;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (buf[i].ktr_desc == NULL)
|
if (buf[i].ktr_desc == NULL)
|
||||||
@ -288,7 +291,8 @@ next: if ((c = *p++) == '\0')
|
|||||||
if (!iflag) {
|
if (!iflag) {
|
||||||
if (i == index)
|
if (i == index)
|
||||||
break;
|
break;
|
||||||
i = (i - 1) % entries;
|
if (--i < 0)
|
||||||
|
i = entries - 1;
|
||||||
} else {
|
} else {
|
||||||
if (++i == entries)
|
if (++i == entries)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user