Blame SOURCES/0019-ID-408-fix-sel-list-last-X-listing.patch

4e2c59
From e9b21fcf6820f074f7166ddd993fb1dbb55d5ffc Mon Sep 17 00:00:00 2001
4e2c59
From: Boris Ranto <branto@redhat.com>
4e2c59
Date: Mon, 11 Jan 2016 14:10:15 +0100
4e2c59
Subject: [PATCH] ID 408 - fix sel list last X listing
4e2c59
4e2c59
The events can be removed as desired on certain machines so the only way
4e2c59
to get the proper last X events is to traverse them all not outputting
4e2c59
the first NR_EVENTS - X events.
4e2c59
4e2c59
Signed-off-by: Boris Ranto <branto@redhat.com>
4e2c59
---
4e2c59
 lib/ipmi_sel.c | 25 +++++++++++++++----------
4e2c59
 1 file changed, 15 insertions(+), 10 deletions(-)
4e2c59
4e2c59
diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c
4e2c59
index 243f268..769fbc2 100644
4e2c59
--- a/lib/ipmi_sel.c
4e2c59
+++ b/lib/ipmi_sel.c
4e2c59
@@ -2239,7 +2239,7 @@ __ipmi_sel_savelist_entries(struct ipmi_intf * intf, int count, const char * sav
4e2c59
 
4e2c59
 	if (count < 0) {
4e2c59
 		/** Show only the most recent 'count' records. */
4e2c59
-		int delta;
4e2c59
+		int i;
4e2c59
 		uint16_t entries;
4e2c59
 
4e2c59
 		req.msg.cmd = IPMI_CMD_GET_SEL_INFO;
4e2c59
@@ -2257,15 +2257,20 @@ __ipmi_sel_savelist_entries(struct ipmi_intf * intf, int count, const char * sav
4e2c59
 		if (-count > entries)
4e2c59
 			count = -entries;
4e2c59
 
4e2c59
-		/* Get first record. */
4e2c59
-		next_id = ipmi_sel_get_std_entry(intf, 0, &evt);
4e2c59
-
4e2c59
-		delta = next_id - evt.record_id;
4e2c59
-
4e2c59
-		/* Get last record. */
4e2c59
-		next_id = ipmi_sel_get_std_entry(intf, 0xffff, &evt);
4e2c59
-
4e2c59
-		next_id = evt.record_id + count * delta + delta;
4e2c59
+		for(i = 0; i < entries + count; i++) {
4e2c59
+			next_id = ipmi_sel_get_std_entry(intf, next_id, &evt);
4e2c59
+			if (next_id == 0) {
4e2c59
+				/*
4e2c59
+				 * usually next_id of zero means end but
4e2c59
+				 * retry because some hardware has quirks
4e2c59
+				 * and will return 0 randomly.
4e2c59
+				 */
4e2c59
+				next_id = ipmi_sel_get_std_entry(intf, next_id, &evt);
4e2c59
+				if (next_id == 0) {
4e2c59
+					break;
4e2c59
+				}
4e2c59
+			}
4e2c59
+		}
4e2c59
 	}
4e2c59
 
4e2c59
 	if (savefile != NULL) {
4e2c59
-- 
4e2c59
2.5.5
4e2c59