From 39ad0d62cc91e5bfcf03af4b83da99c7f1edd62d Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Fri, 8 Mar 2013 06:39:54 +0000 Subject: [PATCH] ID: 3603419 - 'lib/ipmi_dcmi.c' - waste of resources Commit moves one #ifdef upwards in the code, so resources are not wasted pointlessly. There is no need to allocate memory for variables/structs and open interface, if we're about to quit immediately because LAN+ support is not enabled. Error message got changed as well and it gets printed on STDERR where it belongs! --- ipmitool/lib/ipmi_dcmi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ipmitool/lib/ipmi_dcmi.c b/ipmitool/lib/ipmi_dcmi.c index b89150e..738f91b 100755 --- a/ipmitool/lib/ipmi_dcmi.c +++ b/ipmitool/lib/ipmi_dcmi.c @@ -445,6 +445,11 @@ void display_capabilities_attributes( static int ipmi_dcmi_prnt_oobDiscover(struct ipmi_intf * intf) { +# ifndef IPMI_INTF_LANPLUS + lprintf(LOG_ERR, + "DCMI Discovery is available only when LANplus(IPMI v2.0) is enabled."); + return (-1); +# else int rc; if (intf->opened == 0 && intf->open != NULL) { @@ -452,11 +457,6 @@ ipmi_dcmi_prnt_oobDiscover(struct ipmi_intf * intf) return (int) NULL; } - #ifndef IPMI_INTF_LANPLUS - printf("Function oobDicover unavailable when lanplus (IPMI v2) is not enabled\n"); - return -1; - - #else struct ipmi_session *s; @@ -520,7 +520,7 @@ ipmi_dcmi_prnt_oobDiscover(struct ipmi_intf * intf) //Lets ping/pong return ipmiv2_lan_ping(intf); - #endif +# endif } /******************************************************************************* * This is the get DCMI Capabilities function to see what the BMC supports. *