From owner-svn-src-all@FreeBSD.ORG Fri Mar 14 21:35:17 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 755934E7; Fri, 14 Mar 2014 21:35:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6267D12F; Fri, 14 Mar 2014 21:35:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2ELZHpY000768; Fri, 14 Mar 2014 21:35:17 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2ELZHM2000767; Fri, 14 Mar 2014 21:35:17 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201403142135.s2ELZHM2000767@svn.freebsd.org> From: Neel Natu Date: Fri, 14 Mar 2014 21:35:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263194 - head/usr.bin/ktrdump X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Mar 2014 21:35:17 -0000 Author: neel Date: Fri Mar 14 21:35:16 2014 New Revision: 263194 URL: http://svnweb.freebsd.org/changeset/base/263194 Log: 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. Modified: head/usr.bin/ktrdump/ktrdump.c Modified: head/usr.bin/ktrdump/ktrdump.c ============================================================================== --- head/usr.bin/ktrdump/ktrdump.c Fri Mar 14 21:18:41 2014 (r263193) +++ head/usr.bin/ktrdump/ktrdump.c Fri Mar 14 21:35:16 2014 (r263194) @@ -219,8 +219,11 @@ main(int ac, char **av) /* * Now tear through the trace buffer. */ - if (!iflag) - i = (index - 1) % entries; + if (!iflag) { + i = index - 1; + if (i < 0) + i = entries - 1; + } tlast = -1; for (;;) { if (buf[i].ktr_desc == NULL) @@ -288,7 +291,8 @@ next: if ((c = *p++) == '\0') if (!iflag) { if (i == index) break; - i = (i - 1) % entries; + if (--i < 0) + i = entries - 1; } else { if (++i == entries) break;