summaryrefslogtreecommitdiff
path: root/lib/ipmi_hpmfwupg.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipmi_hpmfwupg.c')
-rw-r--r--lib/ipmi_hpmfwupg.c179
1 files changed, 95 insertions, 84 deletions
diff --git a/lib/ipmi_hpmfwupg.c b/lib/ipmi_hpmfwupg.c
index bbcffc0..ea9072e 100644
--- a/lib/ipmi_hpmfwupg.c
+++ b/lib/ipmi_hpmfwupg.c
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2006 Kontron Canada, Inc. All Rights Reserved.
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2020 Joyent, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,10 +31,6 @@
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-#define _BSD_SOURCE || \
- (_XOPEN_SOURCE >= 500 || \
- _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \
- !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_mc.h>
@@ -52,12 +49,27 @@
# include <config.h>
#endif
-/* From src/plugins/ipmi_intf.c: */
-uint16_t
-ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf);
+/*
+ * This error code is used as a temporary PATCH to
+ * the latest Open ipmi driver. This PATCH
+ * will be removed once a new Open IPMI driver is released.
+ * (Buggy version = 39)
+ */
+#define ENABLE_OPENIPMI_V39_PATCH
+
+#ifdef ENABLE_OPENIPMI_V39_PATCH
+# define RETRY_COUNT_MAX 3
+static int errorCount;
+# define HPMFWUPG_IS_RETRYABLE(error) \
+ ((((error==0x83)||(error==0x82)||(error==0x80)) && (errorCount++<RETRY_COUNT_MAX))?TRUE:FALSE)
+#else
+# define HPMFWUPG_IS_RETRYABLE(error) FALSE
+#endif
extern int verbose;
+VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
+
int HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename,
int activate, int, int);
int HpmfwupgValidateImageIntegrity(struct HpmfwupgUpgradeCtx *pFwupgCtx);
@@ -117,7 +129,7 @@ int HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
int option,
int *pFlagColdReset);
int
-HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf,
+HpmfwupgPreUpgradeCheck(
struct HpmfwupgUpgradeCtx *pFwupgCtx,
int componentMask, int option);
@@ -507,10 +519,9 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
lprintf(LOG_NOTICE, "\nPerforming upgrade stage:");
}
if (option & VIEW_MODE) {
- rc = HpmfwupgPreUpgradeCheck(intf,
- &fwupgCtx,componentMask, VIEW_MODE);
+ rc = HpmfwupgPreUpgradeCheck(&fwupgCtx,componentMask, VIEW_MODE);
} else {
- rc = HpmfwupgPreUpgradeCheck(intf, &fwupgCtx,
+ rc = HpmfwupgPreUpgradeCheck(&fwupgCtx,
componentMask, option);
if (rc == HPMFWUPG_SUCCESS) {
if (verbose) {
@@ -534,7 +545,7 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
}
if (rc == HPMFWUPG_SUCCESS) {
if (option & VIEW_MODE) {
- /* Dont display anything here in case we are just viewing it */
+ /* Don't display anything here in case we are just viewing it */
lprintf(LOG_NOTICE," ");
} else if (option & COMPARE_MODE) {
lprintf(LOG_NOTICE,
@@ -544,7 +555,7 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
"\nFirmware upgrade procedure successful\n");
}
} else if (option & VIEW_MODE) {
- /* Dont display anything here in case we are just viewing it */
+ /* Don't display anything here in case we are just viewing it */
lprintf(LOG_NOTICE," ");
} else if (option & COMPARE_MODE) {
lprintf(LOG_NOTICE,
@@ -653,7 +664,7 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
if (rc != HPMFWUPG_SUCCESS) {
/* Giving one more chance to user to check whether its OK to continue even if the
* product ID does not match. This is helpful as sometimes we just want to update
- * and dont care whether we have a different product Id. If the user says NO then
+ * and don't care whether we have a different product Id. If the user says NO then
* we need to just bail out from here
*/
if (!((option & FORCE_MODE) || (option & VIEW_MODE))) {
@@ -725,7 +736,7 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
"\n Some components present in the image file are not supported by the IPMC");
return HPMFWUPG_ERROR;
}
- /* Make sure the upgrade is desirable rigth now */
+ /* Make sure the upgrade is desirable right now */
if (pFwupgCtx->targetCap.GlobalCapabilities.bitField.fwUpgUndesirable == 1) {
lprintf(LOG_NOTICE, "\n Upgrade undesirable at this moment");
return HPMFWUPG_ERROR;
@@ -834,7 +845,7 @@ HpmfwupgValidateActionRecordChecksum(struct HpmfwupgActionRecord *pActionRecord)
* is same as target version.
*/
int
-HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf,
+HpmfwupgPreUpgradeCheck(
struct HpmfwupgUpgradeCtx *pFwupgCtx,
int componentMask, int option)
{
@@ -1213,7 +1224,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
if (rc == HPMFWUPG_UPLOAD_BLOCK_LENGTH && !bufLengthIsSet) {
rc = HPMFWUPG_SUCCESS;
/* Retry with a smaller buffer length */
- if (strstr(intf->name,"lan") != NULL && bufLength > 8) {
+ if (strstr(intf->name,"lan") && bufLength > 8) {
bufLength-= 8;
lprintf(LOG_INFO,
"Trying reduced buffer length: %d",
@@ -1304,7 +1315,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
HpmDisplayUpgrade(1,0,0,0);
if ((option & COMPARE_MODE)
&& !pFwupgCtx->genCompProp[pFwupgCtx->componentId].GeneralCompProperties.bitfield.comparisonSupport) {
- printf("| |Comparison isn't supported for given compenent. |\n");
+ printf("| |Comparison isn't supported for given component. |\n");
}
*pImagePtr = pDataInitial + firmwareLength;
}
@@ -1390,27 +1401,26 @@ int
HpmfwupgGetBufferFromFile(char *imageFilename,
struct HpmfwupgUpgradeCtx *pFwupgCtx)
{
- int rc = HPMFWUPG_SUCCESS;
+ int rc = HPMFWUPG_ERROR;
int ret = 0;
FILE *pImageFile = fopen(imageFilename, "rb");
- if (pImageFile == NULL) {
+ if (!pImageFile) {
lprintf(LOG_ERR, "Cannot open image file '%s'",
imageFilename);
- return HPMFWUPG_ERROR;
+ goto ret_no_close;
}
/* Get the raw data in file */
ret = fseek(pImageFile, 0, SEEK_END);
if (ret != 0) {
lprintf(LOG_ERR, "Failed to seek in the image file '%s'",
imageFilename);
- return HPMFWUPG_ERROR;
+ goto ret_close;
}
pFwupgCtx->imageSize = ftell(pImageFile);
pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize);
- if (pFwupgCtx->pImageData == NULL) {
+ if (!pFwupgCtx->pImageData) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
- fclose(pImageFile);
- return HPMFWUPG_ERROR;
+ goto ret_close;
}
rewind(pImageFile);
ret = fread(pFwupgCtx->pImageData,
@@ -1422,9 +1432,14 @@ HpmfwupgGetBufferFromFile(char *imageFilename,
"Failed to read file %s size %d",
imageFilename,
pFwupgCtx->imageSize);
- rc = HPMFWUPG_ERROR;
+ goto ret_close;
}
+
+ rc = HPMFWUPG_SUCCESS;
+
+ret_close:
fclose(pImageFile);
+ret_no_close:
return rc;
}
@@ -1438,11 +1453,11 @@ HpmfwupgGetDeviceId(struct ipmi_intf *intf, struct ipm_devid_rsp *pGetDevId)
req.msg.cmd = BMC_GET_DEVICE_ID;
req.msg.data_len = 0;
rsp = HpmfwupgSendCmd(intf, req, NULL);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error getting device ID.");
return HPMFWUPG_ERROR;
}
- if (rsp->ccode != 0x00) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Error getting device ID.");
lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode,
@@ -1466,12 +1481,12 @@ HpmfwupgGetTargetUpgCapabilities(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgGetTargetUpgCapabilitiesReq);
rsp = HpmfwupgSendCmd(intf, req, NULL);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR,
"Error getting target upgrade capabilities.");
return HPMFWUPG_ERROR;
}
- if (rsp->ccode != 0x00) {
+ if (rsp->ccode) {
lprintf(LOG_ERR,
"Error getting target upgrade capabilities, ccode: 0x%x: %s",
rsp->ccode,
@@ -1507,7 +1522,7 @@ HpmfwupgGetTargetUpgCapabilities(struct ipmi_intf *intf,
pCtx->resp.GlobalCapabilities.bitField.autRollbackOverride ? 'y' : 'n');
lprintf(LOG_NOTICE, "IPMC degraded...........[%c] ",
pCtx->resp.GlobalCapabilities.bitField.ipmcDegradedDurinUpg ? 'y' : 'n');
- lprintf(LOG_NOTICE, "Defered activation......[%c] ",
+ lprintf(LOG_NOTICE, "Deferred activation.....[%c] ",
pCtx->resp.GlobalCapabilities.bitField.deferActivation ? 'y' : 'n');
lprintf(LOG_NOTICE, "Service affected........[%c] ",
pCtx->resp.GlobalCapabilities.bitField.servAffectDuringUpg ? 'y' : 'n');
@@ -1543,12 +1558,12 @@ HpmfwupgGetComponentProperties(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgGetComponentPropertiesReq);
rsp = HpmfwupgSendCmd(intf, req, NULL);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_NOTICE,
"Error getting component properties\n");
return HPMFWUPG_ERROR;
}
- if (rsp->ccode != 0x00) {
+ if (rsp->ccode) {
lprintf(LOG_NOTICE,
"Error getting component properties");
lprintf(LOG_NOTICE,
@@ -1669,11 +1684,11 @@ HpmfwupgAbortUpgrade(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgAbortUpgradeReq);
rsp = HpmfwupgSendCmd(intf, req, NULL);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error - aborting upgrade.");
return HPMFWUPG_ERROR;
}
- if (rsp->ccode != 0x00) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Error aborting upgrade");
lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode,
@@ -1698,14 +1713,14 @@ HpmfwupgInitiateUpgradeAction(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgInitiateUpgradeActionReq);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error initiating upgrade action.");
return HPMFWUPG_ERROR;
}
/* Long duration command handling */
if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) {
rc = HpmfwupgWaitLongDurationCmd(intf, pFwupgCtx);
- } else if (rsp->ccode != 0x00) {
+ } else if (rsp->ccode) {
lprintf(LOG_NOTICE,"Error initiating upgrade action");
lprintf(LOG_NOTICE, "compcode=0x%x: %s",
rsp->ccode,
@@ -1732,7 +1747,7 @@ HpmfwupgUploadFirmwareBlock(struct ipmi_intf *intf,
/* 2 is the size of the upload struct - data */
req.msg.data_len = 2 + count;
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_NOTICE, "Error uploading firmware block.");
return HPMFWUPG_ERROR;
}
@@ -1768,7 +1783,7 @@ HpmfwupgUploadFirmwareBlock(struct ipmi_intf *intf,
/* Long duration command handling */
if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) {
rc = HpmfwupgWaitLongDurationCmd(intf, pFwupgCtx);
- } else if (rsp->ccode != 0x00) {
+ } else if (rsp->ccode) {
/* PATCH --> This validation is to handle retryables errors codes on IPMB bus.
* This will be fixed in the next release of open ipmi and this
* check will have to be removed. (Buggy version = 39)
@@ -1809,7 +1824,7 @@ HpmfwupgFinishFirmwareUpload(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgFinishFirmwareUploadReq);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error fininshing firmware upload.");
return HPMFWUPG_ERROR;
}
@@ -1846,7 +1861,7 @@ HpmfwupgActivateFirmware(struct ipmi_intf *intf,
req.msg.data_len = sizeof(struct HpmfwupgActivateFirmwareReq)
- (!pCtx->req.rollback_override ? 1 : 0);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error activating firmware.");
return HPMFWUPG_ERROR;
}
@@ -1947,7 +1962,7 @@ HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgManualFirmwareRollbackReq);
rsp = HpmfwupgSendCmd(intf, req, &fwupgCtx);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error sending manual rollback.");
return HPMFWUPG_ERROR;
}
@@ -1958,7 +1973,7 @@ HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf,
printf("Waiting firmware rollback...");
fflush(stdout);
rc = HpmfwupgQueryRollbackStatus(intf, &resCmd, &fwupgCtx);
- } else if ( rsp->ccode != 0x00 ) {
+ } else if (rsp->ccode) {
lprintf(LOG_ERR, "Error sending manual rollback");
lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode,
@@ -1985,7 +2000,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgQueryRollbackStatusReq);
/* If we are not in upgrade context, we use default timeout values */
- if (pFwupgCtx != NULL) {
+ if (pFwupgCtx) {
struct HpmfwupgImageHeader *pImageHeader;
if (pFwupgCtx->pImageData) {
pImageHeader = (struct HpmfwupgImageHeader*)pFwupgCtx->pImageData;
@@ -1994,7 +2009,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
rollbackTimeout = 0;
}
/* Use the greater of the two timeouts (header and target caps) */
- rollbackTimeout = MAX(rollbackTimeout,
+ rollbackTimeout = __max(rollbackTimeout,
pFwupgCtx->targetCap.rollbackTimeout) * 5;
} else {
rollbackTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@@ -2021,7 +2036,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
&& ((rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS)
|| (rsp->ccode == IPMI_CC_TIMEOUT))
&& (timeoutSec2 - timeoutSec1 < rollbackTimeout));
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Error getting upgrade status.");
return HPMFWUPG_ERROR;
}
@@ -2065,11 +2080,11 @@ HpmfwupgQuerySelftestResult(struct ipmi_intf *intf, struct HpmfwupgQuerySelftest
unsigned int timeoutSec1, timeoutSec2;
pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER;
/* If we are not in upgrade context, we use default timeout values */
- if (pFwupgCtx != NULL) {
+ if (pFwupgCtx) {
/* Getting selftest timeout from new image */
struct HpmfwupgImageHeader *pImageHeader = (struct HpmfwupgImageHeader*)
pFwupgCtx->pImageData;
- selfTestTimeout = MAX(pImageHeader->selfTestTimeout,
+ selfTestTimeout = __max(pImageHeader->selfTestTimeout,
pFwupgCtx->targetCap.selftestTimeout) * 5;
} else {
selfTestTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@@ -2101,7 +2116,7 @@ HpmfwupgQuerySelftestResult(struct ipmi_intf *intf, struct HpmfwupgQuerySelftest
} while (rsp
&& (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS)
&& (timeoutSec2 - timeoutSec1 < selfTestTimeout));
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_NOTICE, "Error getting upgrade status\n");
return HPMFWUPG_ERROR;
}
@@ -2135,14 +2150,14 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
unsigned int timeoutSec1, timeoutSec2;
unsigned char retry = 0;
/* If we are not in upgrade context, we use default timeout values */
- if (pFwupgCtx != NULL) {
+ if (pFwupgCtx) {
inaccessTimeout = pFwupgCtx->targetCap.inaccessTimeout*5;
upgradeTimeout = pFwupgCtx->targetCap.upgradeTimeout*5;
} else {
/* keeping the inaccessTimeout to 60 seconds results in almost 2900 retries
* So if the target is not available it will be retrying the command for 2900
- * times which is not effecient -So reducing the Timout to 5 seconds which is
- * almost 200 retries if it continuously recieves 0xC3 as completion code.
+ * times which is not efficient -So reducing the Timeout to 5 seconds which is
+ * almost 200 retries if it continuously receives 0xC3 as completion code.
*/
inaccessTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@@ -2151,10 +2166,10 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
do {
static unsigned char isValidSize = FALSE;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
#define HPM_LAN_PACKET_RESIZE_LIMIT 6
/* also covers lanplus */
- if (strstr(intf->name, "lan") != NULL) {
+ if (strstr(intf->name, "lan")) {
static int errorCount=0;
static struct ipmi_rs fakeRsp;
lprintf(LOG_DEBUG,
@@ -2219,7 +2234,7 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
}
}
/* Handle inaccessibility timeout (rsp = NULL if IOL) */
- if (rsp == NULL || rsp->ccode == 0xff || rsp->ccode == 0xc3 || rsp->ccode == 0xd3) {
+ if (!rsp || rsp->ccode == 0xff || rsp->ccode == 0xc3 || rsp->ccode == 0xd3) {
if (inaccessTimeoutCounter < inaccessTimeout) {
timeoutSec2 = time(NULL);
if (timeoutSec2 > timeoutSec1) {
@@ -2272,14 +2287,14 @@ HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf,
unsigned int timeoutSec1, timeoutSec2;
struct HpmfwupgGetUpgradeStatusCtx upgStatusCmd;
/* If we are not in upgrade context, we use default timeout values */
- if (pFwupgCtx != NULL) {
+ if (pFwupgCtx) {
upgradeTimeout = (unsigned int)(pFwupgCtx->targetCap.upgradeTimeout*5);
if (verbose) {
printf("Use File Upgrade Capabilities: %i seconds\n",
upgradeTimeout);
}
} else {
- /* Try to retreive from Caps */
+ /* Try to retrieve from Caps */
struct HpmfwupgGetTargetUpgCapabilitiesCtx targetCapCmd;
if(HpmfwupgGetTargetUpgCapabilities(intf, &targetCapCmd) != HPMFWUPG_SUCCESS) {
upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@@ -2295,13 +2310,9 @@ HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf,
}
}
}
- if (rc == HPMFWUPG_SUCCESS) {
- /* Poll upgrade status until completion or timeout*/
- timeoutSec1 = time(NULL);
- timeoutSec2 = time(NULL);
- rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd,
- pFwupgCtx, 1);
- }
+ /* Poll upgrade status until completion or timeout*/
+ timeoutSec2 = timeoutSec1 = time(NULL);
+ rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd, pFwupgCtx, 1);
while (
/* With KCS: Cover the case where we sometime
* receive d5 (on the first get status) from
@@ -2464,12 +2475,12 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
HpmfwupgPrintUsage();
return HPMFWUPG_ERROR;
}
- if (strcmp(argv[0], "help") == 0) {
+ if (!strcmp(argv[0], "help")) {
HpmfwupgPrintUsage();
return HPMFWUPG_SUCCESS;
- } else if ((strcmp(argv[0], "check") == 0)) {
+ } else if (!strcmp(argv[0], "check")) {
/* hpm check */
- if (argv[1] == NULL) {
+ if (!argv[1]) {
rc = HpmfwupgTargetCheck(intf,VIEW_MODE);
} else {
/* hpm check <filename> */
@@ -2479,18 +2490,18 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
0, VIEW_MODE);
}
}
- } else if (strcmp(argv[0], "upgrade") == 0) {
+ } else if (!strcmp(argv[0], "upgrade")) {
int i =0;
for (i=1; i< argc ; i++) {
- if (strcmp(argv[i],"activate") == 0) {
+ if (!strcmp(argv[i],"activate")) {
activateFlag = 1;
}
/* hpm upgrade <filename> force */
- if (strcmp(argv[i],"force") == 0) {
+ if (!strcmp(argv[i],"force")) {
option |= FORCE_MODE;
}
/* hpm upgrade <filename> component <comp Id> */
- if (strcmp(argv[i],"component") == 0) {
+ if (!strcmp(argv[i],"component")) {
if (i+1 < argc) {
/* Error Checking */
if (str2int(argv[i+1], &componentId) != 0
@@ -2519,7 +2530,7 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
return HPMFWUPG_ERROR;
}
}
- if (strcmp(argv[i],"debug") == 0) {
+ if (!strcmp(argv[i],"debug")) {
option |= DEBUG_MODE;
}
}
@@ -2529,11 +2540,11 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
rc = HpmfwupgUpgrade(intf, argv[1], activateFlag,
componentMask, option);
}
- } else if (strcmp(argv[0], "compare") == 0) {
+ } else if (!strcmp(argv[0], "compare")) {
int i = 0;
for (i=1; i< argc; i++) {
/* hpm compare <file> [component x...] */
- if (strcmp(argv[i],"component") == 0) {
+ if (!strcmp(argv[i],"component")) {
if (i+1 < argc) {
/* Error Checking */
if (str2int(argv[i+1], &componentId) != 0
@@ -2562,7 +2573,7 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
"No component Id provided\n");
return HPMFWUPG_ERROR;
}
- } else if (strcmp(argv[i],"debug") == 0) {
+ } else if (!strcmp(argv[i],"debug")) {
option|= DEBUG_MODE;
}
}
@@ -2572,19 +2583,19 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
rc = HpmfwupgUpgrade(intf, argv[1], 0,
componentMask, option);
}
- } else if ((argc >= 1) && (strcmp(argv[0], "activate") == 0)) {
+ } else if (argc >= 1 && !strcmp(argv[0], "activate")) {
struct HpmfwupgActivateFirmwareCtx cmdCtx;
- if ((argc == 2) && (strcmp(argv[1], "norollback") == 0)) {
+ if (argc == 2 && !strcmp(argv[1], "norollback")) {
cmdCtx.req.rollback_override = 1;
} else {
cmdCtx.req.rollback_override = 0;
}
rc = HpmfwupgActivateFirmware(intf, &cmdCtx, NULL);
- } else if ((argc == 1) && (strcmp(argv[0], "targetcap") == 0)) {
+ } else if (argc == 1 && !strcmp(argv[0], "targetcap")) {
struct HpmfwupgGetTargetUpgCapabilitiesCtx cmdCtx;
verbose++;
rc = HpmfwupgGetTargetUpgCapabilities(intf, &cmdCtx);
- } else if ((argc == 3) && (strcmp(argv[0], "compprop") == 0)) {
+ } else if (argc == 3 && !strcmp(argv[0], "compprop")) {
struct HpmfwupgGetComponentPropertiesCtx cmdCtx;
if (str2uchar(argv[1], &(cmdCtx.req.componentId)) != 0
|| cmdCtx.req.componentId > 7) {
@@ -2606,23 +2617,23 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
}
verbose++;
rc = HpmfwupgGetComponentProperties(intf, &cmdCtx);
- } else if ((argc == 1) && (strcmp(argv[0], "abort") == 0)) {
+ } else if (argc == 1 && !strcmp(argv[0], "abort")) {
struct HpmfwupgAbortUpgradeCtx cmdCtx;
verbose++;
rc = HpmfwupgAbortUpgrade(intf, &cmdCtx);
- } else if ((argc == 1) && (strcmp(argv[0], "upgstatus") == 0)) {
+ } else if (argc == 1 && !strcmp(argv[0], "upgstatus")) {
struct HpmfwupgGetUpgradeStatusCtx cmdCtx;
verbose++;
rc = HpmfwupgGetUpgradeStatus(intf, &cmdCtx, NULL, 0);
- } else if ((argc == 1) && (strcmp(argv[0], "rollback") == 0)) {
+ } else if (argc == 1 && !strcmp(argv[0], "rollback")) {
struct HpmfwupgManualFirmwareRollbackCtx cmdCtx;
verbose++;
rc = HpmfwupgManualFirmwareRollback(intf, &cmdCtx);
- } else if ((argc == 1) && (strcmp(argv[0], "rollbackstatus") == 0)) {
+ } else if (argc == 1 && !strcmp(argv[0], "rollbackstatus")) {
struct HpmfwupgQueryRollbackStatusCtx cmdCtx;
verbose++;
rc = HpmfwupgQueryRollbackStatus(intf, &cmdCtx, NULL);
- } else if ((argc == 1) && (strcmp(argv[0], "selftestresult") == 0)) {
+ } else if (argc == 1 && !strcmp(argv[0], "selftestresult")) {
struct HpmfwupgQuerySelftestResultCtx cmdCtx;
verbose++;
rc = HpmfwupgQuerySelftestResult(intf, &cmdCtx, NULL);