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/protocols/common/osf/uuid.h b/protocols/common/osf/uuid.h
index d5cbd9c..be0e9ea 100644
--- a/protocols/common/osf/uuid.h
+++ b/protocols/common/osf/uuid.h
@@ -12,12 +12,12 @@
 /**
  * Octet length for standard binary encoded UUID in Big Endian byte order (see RFC4122)
  */
-#define OSF_UUID_OCTET_LEN               (16)
+#define OSF_UUID_OCTET_LEN (16)
 
 /**
  * Character length of a canonical form UUID string
  * e.g. 123e4567-e89b-12d3-a456-426614174000
  */
-#define OSF_UUID_CANONICAL_FORM_LEN      (36)
+#define OSF_UUID_CANONICAL_FORM_LEN (36)
 
 #endif /* COMMON_OSF_UUID_H */
diff --git a/protocols/service/fwu/packed-c/fwu_proto.h b/protocols/service/fwu/packed-c/fwu_proto.h
index a1bb644..6cd691a 100644
--- a/protocols/service/fwu/packed-c/fwu_proto.h
+++ b/protocols/service/fwu/packed-c/fwu_proto.h
@@ -8,8 +8,9 @@
 #define FWU_PROTO_H
 
 #include <stdint.h>
-#include <protocols/common/osf/uuid.h>
+
 #include "opcodes.h"
+#include "protocols/common/osf/uuid.h"
 #include "status.h"
 
 /**
@@ -27,19 +28,18 @@
 /**
  * Protocol GUIDs defined in FWU-A specification
  */
-#define FWU_UPDATE_AGENT_CANONICAL_UUID    "6823a838-1b06-470e-9774-0cce8bfb53fd"
-#define FWU_DIRECTORY_CANONICAL_UUID       "deee58d9-5147-4ad3-a290-77666e2341a5"
-#define FWU_METADATA_CANONICAL_UUID        "8a7a84a0-8387-40f6-ab41-a8b9a5a60d23"
+#define FWU_UPDATE_AGENT_CANONICAL_UUID "6823a838-1b06-470e-9774-0cce8bfb53fd"
+#define FWU_DIRECTORY_CANONICAL_UUID	"deee58d9-5147-4ad3-a290-77666e2341a5"
+#define FWU_METADATA_CANONICAL_UUID	"8a7a84a0-8387-40f6-ab41-a8b9a5a60d23"
 
 /**
  * Image directory
  */
-#define FWU_READ_PERM	(1u << 1)
-#define FWU_WRITE_PERM	(1u << 0)
+#define FWU_READ_PERM  (1u << 1)
+#define FWU_WRITE_PERM (1u << 0)
 
-struct __attribute__ ((__packed__)) ts_fwu_image_info_entry
-{
-	uint8_t  img_type_uuid[OSF_UUID_OCTET_LEN];
+struct __attribute__((__packed__)) ts_fwu_image_info_entry {
+	uint8_t img_type_uuid[OSF_UUID_OCTET_LEN];
 	uint32_t client_permissions;
 	uint32_t img_max_size;
 	uint32_t lowest_accepted_version;
@@ -48,8 +48,7 @@
 	uint32_t reserved;
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_image_directory
-{
+struct __attribute__((__packed__)) ts_fwu_image_directory {
 	uint32_t directory_version;
 	uint32_t img_info_offset;
 	uint32_t num_images;
@@ -63,60 +62,51 @@
  * Message parameters
  */
 
-struct __attribute__ ((__packed__)) ts_fwu_discover_out
-{
-	uint8_t  version_major;
-	uint8_t  version_minor;
+struct __attribute__((__packed__)) ts_fwu_discover_out {
+	uint8_t version_major;
+	uint8_t version_minor;
 	uint16_t num_func;
-	uint8_t  function_presence[];
+	uint8_t function_presence[];
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_open_in
-{
-	uint8_t   image_type_uuid[OSF_UUID_OCTET_LEN];
+struct __attribute__((__packed__)) ts_fwu_open_in {
+	uint8_t image_type_uuid[OSF_UUID_OCTET_LEN];
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_open_out
-{
+struct __attribute__((__packed__)) ts_fwu_open_out {
 	uint32_t handle;
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_write_stream_in
-{
+struct __attribute__((__packed__)) ts_fwu_write_stream_in {
 	uint32_t handle;
 	uint32_t data_len;
-	uint8_t  payload[];
+	uint8_t payload[];
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_read_stream_in
-{
+struct __attribute__((__packed__)) ts_fwu_read_stream_in {
 	uint32_t handle;
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_read_stream_out
-{
+struct __attribute__((__packed__)) ts_fwu_read_stream_out {
 	uint32_t read_bytes;
 	uint32_t total_bytes;
-	uint8_t  payload[];
+	uint8_t payload[];
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_commit_in
-{
+struct __attribute__((__packed__)) ts_fwu_commit_in {
 	uint32_t handle;
 	uint32_t acceptance_req;
 	uint32_t max_atomic_len;
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_commit_out
-{
+struct __attribute__((__packed__)) ts_fwu_commit_out {
 	uint32_t progress;
 	uint32_t total_work;
 };
 
-struct __attribute__ ((__packed__)) ts_fwu_accept_image_in
-{
+struct __attribute__((__packed__)) ts_fwu_accept_image_in {
 	uint32_t reserved;
-	uint8_t  image_type_uuid[OSF_UUID_OCTET_LEN];
+	uint8_t image_type_uuid[OSF_UUID_OCTET_LEN];
 };
 
 #endif /* FWU_PROTO_H */
diff --git a/protocols/service/fwu/packed-c/metadata.h b/protocols/service/fwu/packed-c/metadata.h
index b89cc9e..7a3c4fb 100644
--- a/protocols/service/fwu/packed-c/metadata.h
+++ b/protocols/service/fwu/packed-c/metadata.h
@@ -16,7 +16,7 @@
  * With the default configuration, a dual bank A/B scheme is used.
  */
 #ifndef FWU_METADATA_NUM_BANKS
-#define FWU_METADATA_NUM_BANKS            (2)
+#define FWU_METADATA_NUM_BANKS (2)
 #endif
 
 #endif /* FWU_PROTO_METADATA_H */
diff --git a/protocols/service/fwu/packed-c/metadata_v1.h b/protocols/service/fwu/packed-c/metadata_v1.h
index 2271c9b..cb264da 100644
--- a/protocols/service/fwu/packed-c/metadata_v1.h
+++ b/protocols/service/fwu/packed-c/metadata_v1.h
@@ -12,24 +12,24 @@
 #define FWU_PROTO_METADATA_V1_H
 
 #include <stdint.h>
-#include <protocols/common/osf/uuid.h>
+
 #include "metadata.h"
+#include "protocols/common/osf/uuid.h"
 
 /**
  * FWU metadata version corresponding to these structure definitions.
  */
-#define FWU_METADATA_VERSION           (1)
+#define FWU_METADATA_VERSION (1)
 
 /**
  * The number of image entries in the metadata structure.
  */
 #ifndef FWU_METADATA_NUM_IMAGE_ENTRIES
-#define FWU_METADATA_NUM_IMAGE_ENTRIES    (1)
+#define FWU_METADATA_NUM_IMAGE_ENTRIES (1)
 #endif
 
 /* Properties of image in a bank */
-struct __attribute__ ((__packed__)) fwu_image_properties {
-
+struct __attribute__((__packed__)) fwu_image_properties {
 	/* UUID of the image in this bank */
 	uint8_t img_uuid[OSF_UUID_OCTET_LEN];
 
@@ -41,12 +41,10 @@
 
 	/* reserved (MBZ) */
 	uint32_t reserved;
-
 };
 
 /* Image entry information */
-struct __attribute__ ((__packed__)) fwu_image_entry {
-
+struct __attribute__((__packed__)) fwu_image_entry {
 	/* UUID identifying the image type */
 	uint8_t img_type_uuid[OSF_UUID_OCTET_LEN];
 
@@ -55,7 +53,6 @@
 
 	/* Properties of images with img_type_uuid in the different FW banks */
 	struct fwu_image_properties img_props[FWU_METADATA_NUM_BANKS];
-
 };
 
 /*
@@ -65,8 +62,7 @@
  * 2. Rollback to previous working FW bank.
  * 3. Get properties of all images present in all banks.
  */
-struct __attribute__ ((__packed__)) fwu_metadata {
-
+struct __attribute__((__packed__)) fwu_metadata {
 	/* Metadata CRC value */
 	uint32_t crc_32;
 
@@ -81,7 +77,6 @@
 
 	/* Image entry information */
 	struct fwu_image_entry img_entry[FWU_METADATA_NUM_IMAGE_ENTRIES];
-
 };
 
 #endif /* FWU_PROTO_METADATA_V1_H */
diff --git a/protocols/service/fwu/packed-c/metadata_v2.h b/protocols/service/fwu/packed-c/metadata_v2.h
index 5cac380..33efb33 100644
--- a/protocols/service/fwu/packed-c/metadata_v2.h
+++ b/protocols/service/fwu/packed-c/metadata_v2.h
@@ -12,14 +12,15 @@
 #define FWU_PROTO_METADATA_V2_H
 
 #include <stdint.h>
-#include <protocols/common/osf/uuid.h>
+
 #include "metadata.h"
+#include "protocols/common/osf/uuid.h"
 
 /* Bank state definitions */
-#define FWU_METADATA_V2_NUM_BANK_STATES      (4)
-#define FWU_METADATA_V2_BANK_STATE_INVALID   (0xff)
-#define FWU_METADATA_V2_BANK_STATE_VALID     (0xfe)
-#define FWU_METADATA_V2_BANK_STATE_ACCEPTED  (0xfc)
+#define FWU_METADATA_V2_NUM_BANK_STATES	    (4)
+#define FWU_METADATA_V2_BANK_STATE_INVALID  (0xff)
+#define FWU_METADATA_V2_BANK_STATE_VALID    (0xfe)
+#define FWU_METADATA_V2_BANK_STATE_ACCEPTED (0xfc)
 
 /*
  * Version 2 FWU metadata data structure (mandatory)
@@ -27,8 +28,7 @@
  * The metadata structure is variable length. The actual length is determined
  * from the metadata_size member.
  */
-struct __attribute__ ((__packed__)) fwu_metadata {
-
+struct __attribute__((__packed__)) fwu_metadata {
 	/* Metadata CRC value */
 	uint32_t crc_32;
 
@@ -49,12 +49,10 @@
 
 	/* Bank state bitmaps */
 	uint8_t bank_state[FWU_METADATA_V2_NUM_BANK_STATES];
-
 };
 
 /* Properties of image in a bank */
-struct __attribute__ ((__packed__)) fwu_img_bank_info {
-
+struct __attribute__((__packed__)) fwu_img_bank_info {
 	/* UUID of the image in this bank */
 	uint8_t img_uuid[OSF_UUID_OCTET_LEN];
 
@@ -66,12 +64,10 @@
 
 	/* reserved (MBZ) */
 	uint32_t reserved;
-
 };
 
 /* Image entry information */
-struct __attribute__ ((__packed__)) fwu_image_entry {
-
+struct __attribute__((__packed__)) fwu_image_entry {
 	/* UUID identifying the image type */
 	uint8_t img_type_uuid[OSF_UUID_OCTET_LEN];
 
@@ -80,7 +76,6 @@
 
 	/* Per-bank info related to the image */
 	struct fwu_img_bank_info img_bank_info[FWU_METADATA_NUM_BANKS];
-
 };
 
 /*
@@ -92,8 +87,7 @@
  * not required. The fw_store_desc is assumed to be present if metadata_size
  * > header_size.
  */
-struct __attribute__ ((__packed__)) fwu_fw_store_desc {
-
+struct __attribute__((__packed__)) fwu_fw_store_desc {
 	/* Number of banks */
 	uint8_t num_banks;
 
diff --git a/protocols/service/fwu/packed-c/opcodes.h b/protocols/service/fwu/packed-c/opcodes.h
index b900677..1905a65 100644
--- a/protocols/service/fwu/packed-c/opcodes.h
+++ b/protocols/service/fwu/packed-c/opcodes.h
@@ -10,15 +10,15 @@
 /**
  * Service-level opcodes
  */
-#define TS_FWU_OPCODE_BASE             (0x10)
-#define TS_FWU_OPCODE_BEGIN_STAGING    (TS_FWU_OPCODE_BASE + 0)
-#define TS_FWU_OPCODE_END_STAGING      (TS_FWU_OPCODE_BASE + 1)
-#define TS_FWU_OPCODE_CANCEL_STAGING   (TS_FWU_OPCODE_BASE + 2)
-#define TS_FWU_OPCODE_OPEN             (TS_FWU_OPCODE_BASE + 3)
-#define TS_FWU_OPCODE_WRITE_STREAM     (TS_FWU_OPCODE_BASE + 4)
-#define TS_FWU_OPCODE_READ_STREAM      (TS_FWU_OPCODE_BASE + 5)
-#define TS_FWU_OPCODE_COMMIT           (TS_FWU_OPCODE_BASE + 6)
-#define TS_FWU_OPCODE_ACCEPT_IMAGE     (TS_FWU_OPCODE_BASE + 7)
-#define TS_FWU_OPCODE_SELECT_PREVIOUS  (TS_FWU_OPCODE_BASE + 8)
+#define TS_FWU_OPCODE_BASE	      (0x10)
+#define TS_FWU_OPCODE_BEGIN_STAGING   (TS_FWU_OPCODE_BASE + 0)
+#define TS_FWU_OPCODE_END_STAGING     (TS_FWU_OPCODE_BASE + 1)
+#define TS_FWU_OPCODE_CANCEL_STAGING  (TS_FWU_OPCODE_BASE + 2)
+#define TS_FWU_OPCODE_OPEN	      (TS_FWU_OPCODE_BASE + 3)
+#define TS_FWU_OPCODE_WRITE_STREAM    (TS_FWU_OPCODE_BASE + 4)
+#define TS_FWU_OPCODE_READ_STREAM     (TS_FWU_OPCODE_BASE + 5)
+#define TS_FWU_OPCODE_COMMIT	      (TS_FWU_OPCODE_BASE + 6)
+#define TS_FWU_OPCODE_ACCEPT_IMAGE    (TS_FWU_OPCODE_BASE + 7)
+#define TS_FWU_OPCODE_SELECT_PREVIOUS (TS_FWU_OPCODE_BASE + 8)
 
 #endif /* FWU_PROTO_OPCODES_H */
diff --git a/protocols/service/fwu/packed-c/status.h b/protocols/service/fwu/packed-c/status.h
index b53e8b8..6d3e90b 100644
--- a/protocols/service/fwu/packed-c/status.h
+++ b/protocols/service/fwu/packed-c/status.h
@@ -10,14 +10,14 @@
 /**
  * Service-level status codes
  */
-#define FWU_STATUS_SUCCESS       ((int32_t)0)
-#define FWU_STATUS_UNKNOWN       ((int32_t)-1)
-#define FWU_STATUS_BUSY          ((int32_t)-2)
+#define FWU_STATUS_SUCCESS	 ((int32_t)0)
+#define FWU_STATUS_UNKNOWN	 ((int32_t)-1)
+#define FWU_STATUS_BUSY		 ((int32_t)-2)
 #define FWU_STATUS_OUT_OF_BOUNDS ((int32_t)-3)
-#define FWU_STATUS_AUTH_FAIL     ((int32_t)-4)
+#define FWU_STATUS_AUTH_FAIL	 ((int32_t)-4)
 #define FWU_STATUS_NO_PERMISSION ((int32_t)-5)
-#define FWU_STATUS_DENIED        ((int32_t)-6)
-#define FWU_STATUS_RESUME        ((int32_t)-7)
+#define FWU_STATUS_DENIED	 ((int32_t)-6)
+#define FWU_STATUS_RESUME	 ((int32_t)-7)
 #define FWU_STATUS_NOT_AVAILABLE ((int32_t)-8)
 
 #endif /* FWU_PROTO_STATUS_H */