From eb65a625a2185cd22cc6a8aaf91e34c65b1d682c Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Sun, 7 Jul 2013 11:52:06 +0000 Subject: [PATCH] ID: 28 - 'lib/ipmi_delloem.c' - clean up the code ipmi_lcd_get_info - simplify - Remove pointless ``if () { } else { }'' and return immediately on error. --- ipmitool/lib/ipmi_delloem.c | 69 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/ipmitool/lib/ipmi_delloem.c b/ipmitool/lib/ipmi_delloem.c index d0c3b48..6fb61d5 100644 --- a/ipmitool/lib/ipmi_delloem.c +++ b/ipmitool/lib/ipmi_delloem.c @@ -975,41 +975,40 @@ ipmi_lcd_get_info(struct ipmi_intf * intf) if (ipmi_lcd_get_configure_command(intf, &command) != 0) { return -1; - } else { - if (command == IPMI_DELL_LCD_CONFIG_DEFAULT) { - memset(lcdstring,0,IPMI_DELL_LCD_STRING_LENGTH_MAX+1); - if (ipmi_lcd_get_platform_model_name(intf, lcdstring, - IPMI_DELL_LCD_STRING_LENGTH_MAX, - IPMI_DELL_PLATFORM_MODEL_NAME_SELECTOR) != 0) { - return (-1); - } - printf(" Setting: default\n"); - printf(" Line 1: %s\n", lcdstring); - } else if (command == IPMI_DELL_LCD_CONFIG_NONE) { - printf(" Setting: none\n"); - } else if (command == IPMI_DELL_LCD_CONFIG_USER_DEFINED) { - printf(" Setting: custom\n"); - rc = ipmi_mc_getsysinfo(intf, IPMI_DELL_LCD_GET_CAPS_SELECTOR, 0, 0, - sizeof(lcd_caps), &lcd_caps); - if (rc < 0) { - lprintf(LOG_ERR, "Error getting LCD capabilities."); - return -1; - } else if ((rc == 0xc1) || (rc == 0xcb)) { - lprintf(LOG_ERR, "Error getting LCD capabilities: " - "Command not supported on this system."); - } else if (rc > 0) { - lprintf(LOG_ERR, "Error getting LCD capabilities: %s", - val2str(rc, completion_code_vals)); - return -1; - } - if (lcd_caps.number_lines > 0) { - memset(lcdstring, 0, IPMI_DELL_LCD_STRING_LENGTH_MAX + 1); - rc = ipmi_lcd_get_single_line_text(intf, lcdstring, - lcd_caps.max_chars[0]); - printf(" Text: %s\n", lcdstring); - } else { - printf(" No lines to show\n"); - } + } + if (command == IPMI_DELL_LCD_CONFIG_DEFAULT) { + memset(lcdstring,0,IPMI_DELL_LCD_STRING_LENGTH_MAX+1); + if (ipmi_lcd_get_platform_model_name(intf, lcdstring, + IPMI_DELL_LCD_STRING_LENGTH_MAX, + IPMI_DELL_PLATFORM_MODEL_NAME_SELECTOR) != 0) { + return (-1); + } + printf(" Setting: default\n"); + printf(" Line 1: %s\n", lcdstring); + } else if (command == IPMI_DELL_LCD_CONFIG_NONE) { + printf(" Setting: none\n"); + } else if (command == IPMI_DELL_LCD_CONFIG_USER_DEFINED) { + printf(" Setting: custom\n"); + rc = ipmi_mc_getsysinfo(intf, IPMI_DELL_LCD_GET_CAPS_SELECTOR, 0, 0, + sizeof(lcd_caps), &lcd_caps); + if (rc < 0) { + lprintf(LOG_ERR, "Error getting LCD capabilities."); + return -1; + } else if ((rc == 0xc1) || (rc == 0xcb)) { + lprintf(LOG_ERR, "Error getting LCD capabilities: " + "Command not supported on this system."); + } else if (rc > 0) { + lprintf(LOG_ERR, "Error getting LCD capabilities: %s", + val2str(rc, completion_code_vals)); + return -1; + } + if (lcd_caps.number_lines > 0) { + memset(lcdstring, 0, IPMI_DELL_LCD_STRING_LENGTH_MAX + 1); + rc = ipmi_lcd_get_single_line_text(intf, lcdstring, + lcd_caps.max_chars[0]); + printf(" Text: %s\n", lcdstring); + } else { + printf(" No lines to show\n"); } } return 0;