Fix static analysis errors
Fix checkpatch and cppcheck findings in newly added FWU files.
Change-Id: Ie6a877e65b758399647ceda345ae22081d911f8e
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
diff --git a/deployments/fwu/env/posix/cmd_update_image.cpp b/deployments/fwu/env/posix/cmd_update_image.cpp
index 8e1014f..06c13a6 100644
--- a/deployments/fwu/env/posix/cmd_update_image.cpp
+++ b/deployments/fwu/env/posix/cmd_update_image.cpp
@@ -4,22 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "cmd_update_image.h"
+
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <common/uuid/uuid.h>
-#include "cmd_update_image.h"
+#include "common/uuid/uuid.h"
-int cmd_update_image(
- fwu_app &app,
- const std::string &img_type_uuid,
- const std::string &img_filename)
+int cmd_update_image(fwu_app &app, const std::string &img_type_uuid,
+ const std::string &img_filename)
{
FILE *fp = fopen(img_filename.c_str(), "rb");
if (!fp) {
-
printf("Error: failed to open image file: %s\n", img_filename.c_str());
return -1;
}
@@ -33,7 +31,6 @@
uint8_t *img_buf = (uint8_t *)malloc(img_size);
if (!img_buf) {
-
fclose(fp);
printf("Error: failed to allocate image buffer\n");
return -1;
@@ -41,8 +38,8 @@
/* Read file contents into buffer */
if (fread(img_buf, 1, img_size, fp)) {
-
fclose(fp);
+ free(img_buf);
printf("Error: failed to read image file\n");
return -1;
}