Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 May 2014 15:31:02 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r266402 - stable/8/usr.sbin/mfiutil
Message-ID:  <201405181531.s4IFV26X079450@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Sun May 18 15:31:02 2014
New Revision: 266402
URL: http://svnweb.freebsd.org/changeset/base/266402

Log:
  MFC 264766:
  - Fix an off by one error when checking for the stop event.  This
    resulted in not showing the most recent event by default.
  - When the stop even is hit, break out of the outer loop to stop
    fetching more events.

Modified:
  stable/8/usr.sbin/mfiutil/mfi_evt.c
Directory Properties:
  stable/8/usr.sbin/mfiutil/   (props changed)

Modified: stable/8/usr.sbin/mfiutil/mfi_evt.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_evt.c	Sun May 18 15:29:00 2014	(r266401)
+++ stable/8/usr.sbin/mfiutil/mfi_evt.c	Sun May 18 15:31:02 2014	(r266402)
@@ -33,6 +33,7 @@
 #include <sys/errno.h>
 #include <err.h>
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <strings.h>
@@ -534,6 +535,7 @@ show_events(int ac, char **av)
 	struct mfi_evt_log_state info;
 	struct mfi_evt_list *list;
 	union mfi_evt filter;
+	bool first;
 	long val;
 	char *cp;
 	ssize_t size;
@@ -640,7 +642,9 @@ show_events(int ac, char **av)
 		close(fd);
 		return (ENOMEM);
 	}
-	for (seq = start;;) {
+	first = true;
+	seq = start;
+	for (;;) {
 		if (mfi_get_events(fd, list, num_events, filter, seq,
 		    &status) < 0) {
 			error = errno;
@@ -650,8 +654,6 @@ show_events(int ac, char **av)
 			return (error);
 		}
 		if (status == MFI_STAT_NOT_FOUND) {
-			if (seq == start)
-				warnx("No matching events found");
 			break;
 		}
 		if (status != MFI_STAT_OK) {
@@ -669,13 +671,14 @@ show_events(int ac, char **av)
 			 * the case that our stop point is earlier in
 			 * the buffer than our start point.
 			 */
-			if (list->event[i].seq >= stop) {
+			if (list->event[i].seq > stop) {
 				if (start <= stop)
-					break;
+					goto finish;
 				else if (list->event[i].seq < start)
-					break;
+					goto finish;
 			}
 			mfi_decode_evt(fd, &list->event[i], verbose);
+			first = false;
 		}
 
 		/*
@@ -686,6 +689,9 @@ show_events(int ac, char **av)
 		seq = list->event[list->count - 1].seq + 1;
 			
 	}
+finish:
+	if (first)
+		warnx("No matching events found");
 
 	free(list);
 	close(fd);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405181531.s4IFV26X079450>