diff options
author | Josef Moellers <jmoellers@suse.de> | 2019-01-24 09:35:02 +0100 |
---|---|---|
committer | Alexander Amelkin <mocbuhtig@amelkin.msk.ru> | 2019-01-24 15:22:21 +0300 |
commit | 7941806a9b7470e503d59f20713ef36269381ed2 (patch) | |
tree | 26c2531ebab93450c416091be89bf06525cbe557 /lib | |
parent | 4631d3f9429be573145a137e49c34d420abf566c (diff) | |
download | ipmitool-7941806a9b7470e503d59f20713ef36269381ed2.tar.gz |
hpm: Adhere to centralized exiting
Replace `return`s with `goto`s to appropriate labels
(with or without closing the file).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ipmi_hpmfwupg.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/ipmi_hpmfwupg.c b/lib/ipmi_hpmfwupg.c index c589009..12671ce 100644 --- a/lib/ipmi_hpmfwupg.c +++ b/lib/ipmi_hpmfwupg.c @@ -1385,28 +1385,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) { 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); - fclose(pImageFile); - return HPMFWUPG_ERROR; + goto ret_close; } pFwupgCtx->imageSize = ftell(pImageFile); pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize); if (!pFwupgCtx->pImageData) { lprintf(LOG_ERR, "ipmitool: malloc failure"); - fclose(pImageFile); - return HPMFWUPG_ERROR; + goto ret_close; } rewind(pImageFile); ret = fread(pFwupgCtx->pImageData, @@ -1418,9 +1416,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; } |