ID 408 - fix sel list last X listing

The events can be removed as desired on certain machines so the only way
to get the proper last X events is to traverse them all not outputting
the first NR_EVENTS - X events.

Signed-off-by: Boris Ranto <branto@redhat.com>
This commit is contained in:
Boris Ranto 2016-01-11 14:10:15 +01:00 committed by Zdenek Styblik
parent eb94a394ba
commit ccfa5aec4f

View File

@ -2255,7 +2255,7 @@ __ipmi_sel_savelist_entries(struct ipmi_intf * intf, int count, const char * sav
if (count < 0) { if (count < 0) {
/** Show only the most recent 'count' records. */ /** Show only the most recent 'count' records. */
int delta; int i;
uint16_t entries; uint16_t entries;
req.msg.cmd = IPMI_CMD_GET_SEL_INFO; req.msg.cmd = IPMI_CMD_GET_SEL_INFO;
@ -2273,15 +2273,20 @@ __ipmi_sel_savelist_entries(struct ipmi_intf * intf, int count, const char * sav
if (-count > entries) if (-count > entries)
count = -entries; count = -entries;
/* Get first record. */ for(i = 0; i < entries + count; i++) {
next_id = ipmi_sel_get_std_entry(intf, 0, &evt); next_id = ipmi_sel_get_std_entry(intf, next_id, &evt);
if (next_id == 0) {
delta = next_id - evt.record_id; /*
* usually next_id of zero means end but
/* Get last record. */ * retry because some hardware has quirks
next_id = ipmi_sel_get_std_entry(intf, 0xffff, &evt); * and will return 0 randomly.
*/
next_id = evt.record_id + count * delta + delta; next_id = ipmi_sel_get_std_entry(intf, next_id, &evt);
if (next_id == 0) {
break;
}
}
}
} }
if (savefile != NULL) { if (savefile != NULL) {