summaryrefslogtreecommitdiff
path: root/lib/ipmi_ime.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipmi_ime.c')
-rw-r--r--[-rwxr-xr-x]lib/ipmi_ime.c90
1 files changed, 36 insertions, 54 deletions
diff --git a/lib/ipmi_ime.c b/lib/ipmi_ime.c
index 6bdca3b..5499eba 100755..100644
--- a/lib/ipmi_ime.c
+++ b/lib/ipmi_ime.c
@@ -202,11 +202,11 @@ static int ImeGetInfo(struct ipmi_intf *intf)
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Get Device ID command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Get Device ID command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -240,8 +240,7 @@ static int ImeGetInfo(struct ipmi_intf *intf)
{
rc = IME_SUCCESS;
printf("Manufacturer Name : %s\n",
- val2str( (long)IPM_DEV_MANUFACTURER_ID(devid->manufacturer_id),
- ipmi_oem_info) );
+ OEM_MFG_STRING(devid->manufacturer_id));
printf("Product ID : %u (0x%02x%02x)\n",
buf2short((uint8_t *)(devid->product_id)),
@@ -251,7 +250,7 @@ static int ImeGetInfo(struct ipmi_intf *intf)
(devid->product_id[1]<<8)+devid->product_id[0],
ipmi_oem_product_info);
- if (product!=NULL)
+ if (product)
{
printf("Product Name : %s\n", product);
}
@@ -357,12 +356,7 @@ static int ImeUpgrade(struct ipmi_intf *intf, char* imageFilename)
rc = ImeImageCtxFromFile(imageFilename, &imgCtx);
- if(
- (rc == IME_ERROR) ||
- (imgCtx.pData == NULL) ||
- (imgCtx.size == 0)
- )
- {
+ if (rc == IME_ERROR || !imgCtx.pData || !imgCtx.size) {
return IME_ERROR;
}
@@ -510,11 +504,11 @@ static int ImeUpdatePrepare(struct ipmi_intf *intf)
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -545,11 +539,11 @@ static int ImeUpdateOpenArea(struct ipmi_intf *intf)
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "UpdateOpenArea command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "UpdateOpenArea command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -585,11 +579,11 @@ static int ImeUpdateWriteArea(
req.msg.data_len = length + 1;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "UpdateWriteArea command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "UpdateWriteArea command failed: %s",
val2str(rsp->ccode, completion_code_vals));
if( rsp->ccode == 0x80) // restart operation
@@ -632,11 +626,11 @@ static int ImeUpdateCloseArea(
req.msg.data_len = length;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "UpdateCloseArea command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "UpdateCloseArea command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -666,11 +660,11 @@ static int ImeUpdateGetStatus(struct ipmi_intf *intf, tImeStatus *pStatus )
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -739,11 +733,11 @@ static int ImeUpdateGetCapabilities(struct ipmi_intf *intf, tImeCaps *pCaps )
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -779,11 +773,11 @@ static int ImeUpdateRegisterUpdate(struct ipmi_intf *intf, tImeUpdateType type)
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -810,11 +804,11 @@ static int ImeUpdateShowStatus(struct ipmi_intf *intf)
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@@ -879,15 +873,13 @@ static int ImeImageCtxFromFile(
{
int rc = IME_SUCCESS;
FILE* pImageFile = fopen(imageFilename, "rb");
-
- if ( pImageFile == NULL )
- {
+
+ if (!pImageFile) {
lprintf(LOG_NOTICE,"Cannot open image file %s", imageFilename);
rc = IME_ERROR;
}
-
- if ( rc == IME_SUCCESS )
- {
+
+ if (rc == IME_SUCCESS) {
/* Get the raw data in file */
fseek(pImageFile, 0, SEEK_END);
pImageCtx->size = ftell(pImageFile);
@@ -901,32 +893,26 @@ static int ImeImageCtxFromFile(
pImageCtx->pData = malloc(sizeof(unsigned char)*pImageCtx->size);
rewind(pImageFile);
- if ( pImageCtx->pData != NULL )
- {
- if (pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char),
- pImageCtx->size, pImageFile))
- rc = IME_ERROR;
- }
- else
+ if (!pImageCtx->pData
+ || pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char),
+ pImageCtx->size, pImageFile))
{
rc = IME_ERROR;
}
}
-
+
// Calculate checksum CRC8
if ( rc == IME_SUCCESS )
{
pImageCtx->crc8 = ImeCrc8(pImageCtx->size, pImageCtx->pData);
}
-
- if( pImageFile != NULL)
- {
+ if (pImageFile) {
fclose(pImageFile);
}
-
+
return rc;
-}
+}
static uint8_t ImeCrc8( uint32_t length, uint8_t * pBuf )
{
@@ -1002,16 +988,13 @@ int ipmi_ime_main(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_DEBUG,"ipmi_ime_main()");
- if ( (argc == 0) || (strcmp(argv[0], "help") == 0) )
- {
+ if (!argc || !strcmp(argv[0], "help")) {
ImePrintUsage();
}
- else if ( (argc == 0) || (strcmp(argv[0], "info") == 0) )
- {
+ else if (!strcmp(argv[0], "info")) {
rc = ImeGetInfo(intf);
}
- else if ( strcmp(argv[0], "update") == 0)
- {
+ else if (!strcmp(argv[0], "update")) {
if(argc == 2)
{
lprintf(LOG_NOTICE,"Update using file: %s", argv[1]);
@@ -1023,8 +1006,7 @@ int ipmi_ime_main(struct ipmi_intf * intf, int argc, char ** argv)
rc = IME_ERROR;
}
}
- else if ( (argc == 0) || (strcmp(argv[0], "rollback") == 0) )
- {
+ else if (!strcmp(argv[0], "rollback")) {
rc = ImeManualRollback(intf);
}
else