From b3d258b234b3d4169e05a5d20668c11b75d9d4d0 Mon Sep 17 00:00:00 2001 From: Alexander Amelkin Date: Fri, 20 Jul 2018 19:11:04 +0300 Subject: [PATCH] sel: Minor refactoring Minor code duplication reduction Signed-off-by: Alexander Amelkin --- lib/ipmi_sel.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c index ab4fb76..6b7301c 100644 --- a/lib/ipmi_sel.c +++ b/lib/ipmi_sel.c @@ -2722,13 +2722,12 @@ ipmi_sel_get_time(struct ipmi_intf * intf) rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { - lprintf(LOG_ERR, "Get SEL Time command failed"); - return -1; - } - if (rsp->ccode > 0) { + if (rsp == NULL || rsp->ccode > 0) { lprintf(LOG_ERR, "Get SEL Time command failed: %s", - val2str(rsp->ccode, completion_code_vals)); + rsp + ? val2str(rsp->ccode, completion_code_vals) + : "Unknown" + ); return -1; } if (rsp->data_len != 4) { @@ -2827,13 +2826,12 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string) #endif rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { - lprintf(LOG_ERR, "Set SEL Time command failed"); - return -1; - } - if (rsp->ccode > 0) { + if (rsp == NULL || rsp->ccode > 0) { lprintf(LOG_ERR, "Set SEL Time command failed: %s", - val2str(rsp->ccode, completion_code_vals)); + rsp + ? val2str(rsp->ccode, completion_code_vals) + : "Unknown" + ); return -1; } @@ -2842,8 +2840,6 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string) return 0; } - - static int ipmi_sel_clear(struct ipmi_intf * intf) {