mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
hpm: Adhere to centralized exiting
Replace `return`s with `goto`s to appropriate labels (with or without closing the file).
This commit is contained in:
parent
4631d3f942
commit
7941806a9b
@ -1385,28 +1385,26 @@ int
|
|||||||
HpmfwupgGetBufferFromFile(char *imageFilename,
|
HpmfwupgGetBufferFromFile(char *imageFilename,
|
||||||
struct HpmfwupgUpgradeCtx *pFwupgCtx)
|
struct HpmfwupgUpgradeCtx *pFwupgCtx)
|
||||||
{
|
{
|
||||||
int rc = HPMFWUPG_SUCCESS;
|
int rc = HPMFWUPG_ERROR;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
FILE *pImageFile = fopen(imageFilename, "rb");
|
FILE *pImageFile = fopen(imageFilename, "rb");
|
||||||
if (!pImageFile) {
|
if (!pImageFile) {
|
||||||
lprintf(LOG_ERR, "Cannot open image file '%s'",
|
lprintf(LOG_ERR, "Cannot open image file '%s'",
|
||||||
imageFilename);
|
imageFilename);
|
||||||
return HPMFWUPG_ERROR;
|
goto ret_no_close;
|
||||||
}
|
}
|
||||||
/* Get the raw data in file */
|
/* Get the raw data in file */
|
||||||
ret = fseek(pImageFile, 0, SEEK_END);
|
ret = fseek(pImageFile, 0, SEEK_END);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
lprintf(LOG_ERR, "Failed to seek in the image file '%s'",
|
lprintf(LOG_ERR, "Failed to seek in the image file '%s'",
|
||||||
imageFilename);
|
imageFilename);
|
||||||
fclose(pImageFile);
|
goto ret_close;
|
||||||
return HPMFWUPG_ERROR;
|
|
||||||
}
|
}
|
||||||
pFwupgCtx->imageSize = ftell(pImageFile);
|
pFwupgCtx->imageSize = ftell(pImageFile);
|
||||||
pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize);
|
pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize);
|
||||||
if (!pFwupgCtx->pImageData) {
|
if (!pFwupgCtx->pImageData) {
|
||||||
lprintf(LOG_ERR, "ipmitool: malloc failure");
|
lprintf(LOG_ERR, "ipmitool: malloc failure");
|
||||||
fclose(pImageFile);
|
goto ret_close;
|
||||||
return HPMFWUPG_ERROR;
|
|
||||||
}
|
}
|
||||||
rewind(pImageFile);
|
rewind(pImageFile);
|
||||||
ret = fread(pFwupgCtx->pImageData,
|
ret = fread(pFwupgCtx->pImageData,
|
||||||
@ -1418,9 +1416,14 @@ HpmfwupgGetBufferFromFile(char *imageFilename,
|
|||||||
"Failed to read file %s size %d",
|
"Failed to read file %s size %d",
|
||||||
imageFilename,
|
imageFilename,
|
||||||
pFwupgCtx->imageSize);
|
pFwupgCtx->imageSize);
|
||||||
rc = HPMFWUPG_ERROR;
|
goto ret_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = HPMFWUPG_SUCCESS;
|
||||||
|
|
||||||
|
ret_close:
|
||||||
fclose(pImageFile);
|
fclose(pImageFile);
|
||||||
|
ret_no_close:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user