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/fwu_main.cpp b/deployments/fwu/env/posix/fwu_main.cpp
index e01640a..88bac76 100644
--- a/deployments/fwu/env/posix/fwu_main.cpp
+++ b/deployments/fwu/env/posix/fwu_main.cpp
@@ -7,37 +7,29 @@
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
-#include <string>
 #include <sstream>
+#include <string>
 #include <sys/stat.h>
-#include <common/uuid/uuid.h>
-#include <service/fwu/app/fwu_app.h>
-#include "cmd_update_image.h"
+
 #include "cmd_print_image_dir.h"
 #include "cmd_print_metadata_v1.h"
 #include "cmd_print_metadata_v2.h"
+#include "cmd_update_image.h"
+#include "common/uuid/uuid.h"
+#include "service/fwu/app/fwu_app.h"
 
-static bool option_selected(
-	const char *option_switch,
-	int argc, char *argv[]);
+static bool option_selected(const char *option_switch, int argc, char *argv[]);
 
-static std::string parse_string_option(
-	const char *option_switch,
-	int argc, char *argv[],
-	const char *default_val);
+static std::string parse_string_option(const char *option_switch, int argc, char *argv[],
+				       const char *default_val);
 
-static int parse_numeric_option(
-	const char *option_switch,
-	int argc, char *argv[],
-	int default_val);
+static int parse_numeric_option(const char *option_switch, int argc, char *argv[], int default_val);
 
-static bool file_exists(
-	const std::string &filename);
+static bool file_exists(const std::string &filename);
 
 static void print_usage(void);
 static void print_help(void);
 
-
 int main(int argc, char *argv[])
 {
 	fwu_app app;
@@ -46,10 +38,8 @@
 	std::string img_type_uuid;
 
 	/* Check for help */
-	if (option_selected("-h", argc, argv) ||
-		option_selected("-help", argc, argv) ||
-		option_selected("--help", argc, argv)) {
-
+	if (option_selected("-h", argc, argv) || option_selected("-help", argc, argv) ||
+	    option_selected("--help", argc, argv)) {
 		print_help();
 		return 0;
 	}
@@ -58,7 +48,6 @@
 	if (argc > 1)
 		disk_img_filename = std::string(argv[1]);
 	else {
-
 		printf("Error: missing disk-filename argument\n");
 		print_usage();
 		return -1;
@@ -66,7 +55,6 @@
 
 	/* Check if disk image file exists */
 	if (!file_exists(disk_img_filename)) {
-
 		printf("Error: %s does not exist\n", disk_img_filename.c_str());
 		return -1;
 	}
@@ -75,7 +63,6 @@
 	int status = app.configure(disk_img_filename.c_str());
 
 	if (status) {
-
 		printf("Error: failed to configure with status: %d\n", status);
 		return -1;
 	}
@@ -89,7 +76,6 @@
 	status = app.get_boot_info(boot_index, metadata_version);
 
 	if (status) {
-
 		printf("No recognised metadata, assume default boot index and version\n");
 
 		boot_index = 0;
@@ -110,14 +96,12 @@
 
 	/* Check if image file exists (if one was specified) */
 	if (!update_img_filename.empty() && !file_exists(update_img_filename)) {
-
 		printf("Error: %s does not exist\n", update_img_filename.c_str());
 		return -1;
 	}
 
 	/* Check if img type canonical uuid is well formed */
 	if (!img_type_uuid.empty() && !uuid_is_valid(img_type_uuid.c_str())) {
-
 		printf("Error: image type uuid invalid\n");
 		return -1;
 	}
@@ -127,30 +111,25 @@
 	status = app.init_update_agent(boot_index, metadata_version);
 
 	if (!status) {
-
-		printf("Update agent started: boot index: %d metadata ver: %d\n",
-			boot_index, metadata_version);
+		printf("Update agent started: boot index: %u metadata ver: %u\n", boot_index,
+		       metadata_version);
 
 		if (is_print_img_dir)
 			cmd_print_image_dir(app);
 
 		if (is_print_metadata) {
-
 			if (metadata_version == 1)
 				cmd_print_metadata_v1(app);
 			else if (metadata_version == 2)
 				cmd_print_metadata_v2(app);
 			else
 				printf("Unsupported metadata version\n");
-
 		}
 
 		if (!update_img_filename.empty() && !img_type_uuid.empty()) {
-
 			status = cmd_update_image(app, img_type_uuid, update_img_filename);
 
 		} else if (!update_img_filename.empty() || !img_type_uuid.empty()) {
-
 			printf("Error: both image filename and uuid arguments are needed\n");
 			return -1;
 		}
@@ -164,31 +143,24 @@
 	return status;
 }
 
-static bool option_selected(
-	const char *option_switch,
-	int argc, char *argv[])
+static bool option_selected(const char *option_switch, int argc, char *argv[])
 {
 	bool is_selected = false;
 
 	for (int i = 1; (i < argc) && !is_selected; ++i) {
-
 		is_selected = (strcmp(argv[i], option_switch) == 0);
 	}
 
 	return is_selected;
 }
 
-static std::string parse_string_option(
-	const char *option_switch,
-	int argc, char *argv[],
-	const char *default_val)
+static std::string parse_string_option(const char *option_switch, int argc, char *argv[],
+				       const char *default_val)
 {
 	std::string option = std::string(default_val);
 
 	for (int i = 1; i + 1 < argc; ++i) {
-
 		if (strcmp(argv[i], option_switch) == 0) {
-
 			option = std::string(argv[i + 1]);
 			break;
 		}
@@ -197,17 +169,12 @@
 	return option;
 }
 
-static int parse_numeric_option(
-	const char *option_switch,
-	int argc, char *argv[],
-	int default_val)
+static int parse_numeric_option(const char *option_switch, int argc, char *argv[], int default_val)
 {
 	int option = default_val;
 
 	for (int i = 1; i + 1 < argc; ++i) {
-
 		if (strcmp(argv[i], option_switch) == 0) {
-
 			std::istringstream iss(argv[i + 1]);
 			int val;
 
@@ -233,7 +200,7 @@
 static void print_usage(void)
 {
 	printf("Usage: fwu disk-filename [-dir -meta] [-boot-index number -meta-ver number] "
-		   "[-img filename -img-type uuid]\n");
+	       "[-img filename -img-type uuid]\n");
 }
 
 static void print_help(void)
@@ -249,4 +216,3 @@
 	printf("\t-img\t\tFile containing image update\n");
 	printf("\t-img-type\tCanonical UUID of image to update\n");
 }
-