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/components/service/fwu/agent/fw_directory.c b/components/service/fwu/agent/fw_directory.c
index c794832..ec7486b 100644
--- a/components/service/fwu/agent/fw_directory.c
+++ b/components/service/fwu/agent/fw_directory.c
@@ -5,14 +5,15 @@
  *
  */
 
+#include "fw_directory.h"
+
 #include <assert.h>
 #include <stddef.h>
 #include <string.h>
-#include <protocols/service/fwu/packed-c/status.h>
-#include "fw_directory.h"
 
-void fw_directory_init(
-	struct fw_directory *fw_directory)
+#include "protocols/service/fwu/packed-c/status.h"
+
+void fw_directory_init(struct fw_directory *fw_directory)
 {
 	assert(fw_directory);
 
@@ -22,23 +23,20 @@
 	memset(fw_directory, 0, sizeof(struct fw_directory));
 }
 
-void fw_directory_deinit(
-	struct fw_directory *fw_directory)
+void fw_directory_deinit(struct fw_directory *fw_directory)
 {
 	(void)fw_directory;
 }
 
-void fw_directory_set_boot_info(
-	struct fw_directory *fw_directory,
-	const struct boot_info *boot_info)
+void fw_directory_set_boot_info(struct fw_directory *fw_directory,
+				const struct boot_info *boot_info)
 {
 	assert(fw_directory);
 	fw_directory->boot_info = *boot_info;
 }
 
-int fw_directory_add_image_info(
-	struct fw_directory *fw_directory,
-	const struct image_info *image_info)
+int fw_directory_add_image_info(struct fw_directory *fw_directory,
+				const struct image_info *image_info)
 {
 	assert(fw_directory);
 	assert(image_info);
@@ -46,7 +44,6 @@
 	int status = FWU_STATUS_UNKNOWN;
 
 	if (fw_directory->num_images < FWU_MAX_FW_DIRECTORY_ENTRIES) {
-
 		uint32_t image_index = fw_directory->num_images;
 
 		fw_directory->entries[image_index] = *image_info;
@@ -60,9 +57,8 @@
 	return status;
 }
 
-const struct image_info *fw_directory_find_image_info(
-	const struct fw_directory *fw_directory,
-	const struct uuid_octets *img_type_uuid)
+const struct image_info *fw_directory_find_image_info(const struct fw_directory *fw_directory,
+						      const struct uuid_octets *img_type_uuid)
 {
 	assert(fw_directory);
 	assert(img_type_uuid);
@@ -70,10 +66,8 @@
 	const struct image_info *info = NULL;
 
 	for (size_t i = 0; i < fw_directory->num_images; i++) {
-
 		if (uuid_is_equal(img_type_uuid->octets,
-				fw_directory->entries[i].img_type_uuid.octets)) {
-
+				  fw_directory->entries[i].img_type_uuid.octets)) {
 			info = &fw_directory->entries[i];
 			break;
 		}
@@ -82,16 +76,14 @@
 	return info;
 }
 
-const struct boot_info *fw_directory_get_boot_info(
-	const struct fw_directory *fw_directory)
+const struct boot_info *fw_directory_get_boot_info(const struct fw_directory *fw_directory)
 {
 	assert(fw_directory);
 	return &fw_directory->boot_info;
 }
 
-const struct image_info *fw_directory_get_image_info(
-	const struct fw_directory *fw_directory,
-	size_t index)
+const struct image_info *fw_directory_get_image_info(const struct fw_directory *fw_directory,
+						     size_t index)
 {
 	assert(fw_directory);
 
@@ -103,8 +95,7 @@
 	return info;
 }
 
-size_t fw_directory_num_images(
-	const struct fw_directory *fw_directory)
+size_t fw_directory_num_images(const struct fw_directory *fw_directory)
 {
 	assert(fw_directory);
 	return fw_directory->num_images;
diff --git a/components/service/fwu/agent/fw_directory.h b/components/service/fwu/agent/fw_directory.h
index 119f5bc..6c59554 100644
--- a/components/service/fwu/agent/fw_directory.h
+++ b/components/service/fwu/agent/fw_directory.h
@@ -11,7 +11,8 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <common/uuid/uuid.h>
+
+#include "common/uuid/uuid.h"
 #include "install_type.h"
 
 #ifdef __cplusplus
@@ -23,7 +24,7 @@
  * Can be overridden by an external definition.
  */
 #ifndef FWU_MAX_FW_DIRECTORY_ENTRIES
-#define FWU_MAX_FW_DIRECTORY_ENTRIES	(20)
+#define FWU_MAX_FW_DIRECTORY_ENTRIES (20)
 #endif
 
 /**
@@ -71,7 +72,7 @@
 	/* The version of the currently active version of this image. */
 	uint32_t active_version;
 
-	/* Bitmap of access permissions for this iamge. */
+	/* Bitmap of access permissions for this image. */
 	uint32_t permissions;
 
 	/* The index [0..n] of the image in the fw directory. */
@@ -108,16 +109,14 @@
  *
  * \param[in]  fw_directory    The subject fw_directory
  */
-void fw_directory_init(
-	struct fw_directory *fw_directory);
+void fw_directory_init(struct fw_directory *fw_directory);
 
 /**
  * \brief De-initialise a fw_directory
  *
  * \param[in]  fw_directory    The subject fw_directory
  */
-void fw_directory_deinit(
-	struct fw_directory *fw_directory);
+void fw_directory_deinit(struct fw_directory *fw_directory);
 
 /**
  * \brief Sets the boot_info held by the fw_directory
@@ -127,9 +126,8 @@
  * \param[in]  fw_directory    The subject fw_directory
  * \param[in]  boot_info       boot_info for most recent system boot
  */
-void fw_directory_set_boot_info(
-	struct fw_directory *fw_directory,
-	const struct boot_info *boot_info);
+void fw_directory_set_boot_info(struct fw_directory *fw_directory,
+				const struct boot_info *boot_info);
 
 /**
  * \brief Adds an image_info to the directory
@@ -141,9 +139,8 @@
  *
  * \return FWU status
  */
-int fw_directory_add_image_info(
-	struct fw_directory *fw_directory,
-	const struct image_info *image_info);
+int fw_directory_add_image_info(struct fw_directory *fw_directory,
+				const struct image_info *image_info);
 
 /**
  * \brief Find an image_info entry
@@ -155,9 +152,8 @@
  *
  * \return Pointer to image_info or NULL
  */
-const struct image_info *fw_directory_find_image_info(
-	const struct fw_directory *fw_directory,
-	const struct uuid_octets *img_type_uuid);
+const struct image_info *fw_directory_find_image_info(const struct fw_directory *fw_directory,
+						      const struct uuid_octets *img_type_uuid);
 
 /**
  * \brief Get the boot_info
@@ -166,8 +162,7 @@
  *
  * \return Pointer to the boot_info
  */
-const struct boot_info *fw_directory_get_boot_info(
-	const struct fw_directory *fw_directory);
+const struct boot_info *fw_directory_get_boot_info(const struct fw_directory *fw_directory);
 
 /**
  * \brief Get an image_info by index
@@ -179,9 +174,8 @@
  *
  * \return Pointer to the image_info or NULL if index invalid
  */
-const struct image_info *fw_directory_get_image_info(
-	const struct fw_directory *fw_directory,
-	size_t index);
+const struct image_info *fw_directory_get_image_info(const struct fw_directory *fw_directory,
+						     size_t index);
 
 /**
  * \brief Get the number of image_info entries held
@@ -190,8 +184,7 @@
  *
  * \return Number of entries
  */
-size_t fw_directory_num_images(
-	const struct fw_directory *fw_directory);
+size_t fw_directory_num_images(const struct fw_directory *fw_directory);
 
 #ifdef __cplusplus
 }
diff --git a/components/service/fwu/agent/img_dir_serializer.c b/components/service/fwu/agent/img_dir_serializer.c
index db210bc..d1f44af 100644
--- a/components/service/fwu/agent/img_dir_serializer.c
+++ b/components/service/fwu/agent/img_dir_serializer.c
@@ -5,19 +5,17 @@
  *
  */
 
-#include <assert.h>
-#include <string.h>
-#include <protocols/service/fwu/packed-c/fwu_proto.h>
-#include <service/fwu/fw_store/fw_store.h>
-#include "fw_directory.h"
 #include "img_dir_serializer.h"
 
-int img_dir_serializer_serialize(
-	const struct fw_directory *fw_dir,
-	const struct fw_store *fw_store,
-	uint8_t *buf,
-	size_t buf_size,
-	size_t *data_len)
+#include <assert.h>
+#include <string.h>
+
+#include "fw_directory.h"
+#include "protocols/service/fwu/packed-c/fwu_proto.h"
+#include "service/fwu/fw_store/fw_store.h"
+
+int img_dir_serializer_serialize(const struct fw_directory *fw_dir, const struct fw_store *fw_store,
+				 uint8_t *buf, size_t buf_size, size_t *data_len)
 {
 	size_t serialized_len = img_dir_serializer_get_len(fw_dir);
 
@@ -45,24 +43,19 @@
 
 	/* Serialize image info for each image */
 	for (size_t image_index = 0; image_index < output->num_images; image_index++) {
-
 		const struct image_info *image_info =
 			fw_directory_get_image_info(fw_dir, image_index);
 
 		assert(image_info);
 
 		memcpy(output->img_info_entry[image_index].img_type_uuid,
-			image_info->img_type_uuid.octets,
-			OSF_UUID_OCTET_LEN);
+		       image_info->img_type_uuid.octets, OSF_UUID_OCTET_LEN);
 
-		output->img_info_entry[image_index].client_permissions =
-			image_info->permissions;
-		output->img_info_entry[image_index].img_max_size =
-			image_info->max_size;
+		output->img_info_entry[image_index].client_permissions = image_info->permissions;
+		output->img_info_entry[image_index].img_max_size = image_info->max_size;
 		output->img_info_entry[image_index].lowest_accepted_version =
 			image_info->lowest_accepted_version;
-		output->img_info_entry[image_index].img_version =
-			image_info->active_version;
+		output->img_info_entry[image_index].img_version = image_info->active_version;
 		output->img_info_entry[image_index].accepted =
 			(uint32_t)fw_store_is_accepted(fw_store, image_info);
 	}
@@ -72,10 +65,8 @@
 	return FWU_STATUS_SUCCESS;
 }
 
-size_t img_dir_serializer_get_len(
-	const struct fw_directory *fw_dir)
+size_t img_dir_serializer_get_len(const struct fw_directory *fw_dir)
 {
-	return
-		offsetof(struct ts_fwu_image_directory, img_info_entry) +
-		sizeof(struct ts_fwu_image_info_entry) * fw_directory_num_images(fw_dir);
+	return offsetof(struct ts_fwu_image_directory, img_info_entry) +
+	       sizeof(struct ts_fwu_image_info_entry) * fw_directory_num_images(fw_dir);
 }
diff --git a/components/service/fwu/agent/img_dir_serializer.h b/components/service/fwu/agent/img_dir_serializer.h
index 28274f2..fe8c7ec 100644
--- a/components/service/fwu/agent/img_dir_serializer.h
+++ b/components/service/fwu/agent/img_dir_serializer.h
@@ -36,12 +36,8 @@
  *
  * \return Status
  */
-int img_dir_serializer_serialize(
-	const struct fw_directory *fw_dir,
-	const struct fw_store *fw_store,
-	uint8_t *buf,
-	size_t buf_size,
-	size_t *data_len);
+int img_dir_serializer_serialize(const struct fw_directory *fw_dir, const struct fw_store *fw_store,
+				 uint8_t *buf, size_t buf_size, size_t *data_len);
 
 /**
  * \brief Return the length in bytes of the serialized image directory
@@ -50,8 +46,7 @@
  *
  * \return Size in bytes
  */
-size_t img_dir_serializer_get_len(
-	const struct fw_directory *fw_dir);
+size_t img_dir_serializer_get_len(const struct fw_directory *fw_dir);
 
 #ifdef __cplusplus
 }
diff --git a/components/service/fwu/agent/stream_manager.c b/components/service/fwu/agent/stream_manager.c
index 5284f71..c93bdf1 100644
--- a/components/service/fwu/agent/stream_manager.c
+++ b/components/service/fwu/agent/stream_manager.c
@@ -4,15 +4,16 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <stddef.h>
-#include <string.h>
-#include <protocols/service/fwu/packed-c/status.h>
-#include <service/fwu/fw_store/fw_store.h>
 #include "stream_manager.h"
 
-static uint32_t generate_handle(
-	struct stream_manager *subject,
-	struct stream_context *context)
+#include <stddef.h>
+#include <string.h>
+
+#include "protocols/service/fwu/packed-c/status.h"
+#include "service/fwu/fw_store/fw_store.h"
+
+static uint32_t generate_handle(struct stream_manager *subject,
+				const struct stream_context *const context)
 {
 	/* Handle includes rolling count value to protect against use of a stale handle */
 	uint32_t new_handle = context - subject->contexts;
@@ -27,9 +28,7 @@
 	return handle & 0xffff;
 }
 
-static void add_to_free_list(
-	struct stream_manager *subject,
-	struct stream_context *context)
+static void add_to_free_list(struct stream_manager *subject, struct stream_context *context)
 {
 	context->type = FWU_STREAM_TYPE_NONE;
 	context->handle = 0;
@@ -38,25 +37,18 @@
 	subject->free = context;
 }
 
-static struct stream_context *alloc_stream_context(
-	struct stream_manager *subject,
-	enum fwu_stream_type type,
-	uint32_t *handle)
+static struct stream_context *alloc_stream_context(struct stream_manager *subject,
+						   enum fwu_stream_type type, uint32_t *handle)
 {
 	struct stream_context *context = NULL;
 
 	/* Re-cycle least-recently used context if there are no free contexts */
 	if (!subject->free && subject->active_tail) {
-
-		stream_manager_close(
-			subject,
-			subject->active_tail->handle,
-			false);
+		stream_manager_close(subject, subject->active_tail->handle, false);
 	}
 
 	/* Active contexts are held in a linked list in most recently allocated order */
 	if (subject->free) {
-
 		context = subject->free;
 		subject->free = context->next;
 
@@ -79,9 +71,7 @@
 	return context;
 }
 
-static void free_stream_context(
-	struct stream_manager *subject,
-	struct stream_context *context)
+static void free_stream_context(struct stream_manager *subject, struct stream_context *context)
 {
 	/* Remove from active list */
 	if (context->prev)
@@ -98,17 +88,14 @@
 	add_to_free_list(subject, context);
 }
 
-static struct stream_context *get_active_context(
-	struct stream_manager *subject,
-	uint32_t handle)
+static struct stream_context *get_active_context(struct stream_manager *subject, uint32_t handle)
 {
 	struct stream_context *context = NULL;
 	uint32_t index = index_from_handle(handle);
 
 	if ((index < FWU_STREAM_MANAGER_POOL_SIZE) &&
-		(subject->contexts[index].type != FWU_STREAM_TYPE_NONE) &&
-		(subject->contexts[index].handle == handle)) {
-
+	    (subject->contexts[index].type != FWU_STREAM_TYPE_NONE) &&
+	    (subject->contexts[index].handle == handle)) {
 		/* Handle qualifies an active stream context */
 		context = &subject->contexts[index];
 	}
@@ -116,8 +103,7 @@
 	return context;
 }
 
-void stream_manager_init(
-	struct stream_manager *subject)
+void stream_manager_init(struct stream_manager *subject)
 {
 	subject->free = NULL;
 	subject->active_head = NULL;
@@ -128,17 +114,13 @@
 		add_to_free_list(subject, &subject->contexts[i]);
 }
 
-void stream_manager_deinit(
-	struct stream_manager *subject)
+void stream_manager_deinit(struct stream_manager *subject)
 {
 	(void)subject;
 }
 
-int stream_manager_open_buffer_stream(
-	struct stream_manager *subject,
-	const uint8_t *data,
-	size_t data_len,
-	uint32_t *handle)
+int stream_manager_open_buffer_stream(struct stream_manager *subject, const uint8_t *data,
+				      size_t data_len, uint32_t *handle)
 {
 	struct stream_context *context;
 	int status = FWU_STATUS_UNKNOWN;
@@ -149,22 +131,17 @@
 	 * being updated while a read stream is open.
 	 */
 	for (size_t i = 0; i < FWU_STREAM_MANAGER_POOL_SIZE; i++) {
-
 		context = &subject->contexts[i];
 
 		if ((context->type == FWU_STREAM_TYPE_BUFFER) &&
-			(context->variant.buffer.data == data))
+		    (context->variant.buffer.data == data))
 			free_stream_context(subject, context);
 	}
 
 	/* Allocate and initialize a new stream */
-	context = alloc_stream_context(
-		subject,
-		FWU_STREAM_TYPE_BUFFER,
-		handle);
+	context = alloc_stream_context(subject, FWU_STREAM_TYPE_BUFFER, handle);
 
 	if (context) {
-
 		context->variant.buffer.data = data;
 		context->variant.buffer.data_len = data_len;
 		context->variant.buffer.pos = 0;
@@ -175,12 +152,9 @@
 	return status;
 }
 
-int stream_manager_open_install_stream(
-	struct stream_manager *subject,
-	struct fw_store *fw_store,
-	struct installer *installer,
-	const struct image_info *image_info,
-	uint32_t *stream_handle)
+int stream_manager_open_install_stream(struct stream_manager *subject, struct fw_store *fw_store,
+				       struct installer *installer,
+				       const struct image_info *image_info, uint32_t *stream_handle)
 {
 	struct stream_context *context;
 	int status = FWU_STATUS_UNKNOWN;
@@ -191,23 +165,18 @@
 	 * same installer, resulting in image corruption.
 	 */
 	for (size_t i = 0; i < FWU_STREAM_MANAGER_POOL_SIZE; i++) {
-
 		context = &subject->contexts[i];
 
 		if ((context->type == FWU_STREAM_TYPE_INSTALL) &&
-			(context->variant.install.fw_store == fw_store) &&
-			(context->variant.install.installer == installer))
+		    (context->variant.install.fw_store == fw_store) &&
+		    (context->variant.install.installer == installer))
 			free_stream_context(subject, context);
 	}
 
 	/* Allocate and initialize a new stream */
-	context = alloc_stream_context(
-		subject,
-		FWU_STREAM_TYPE_INSTALL,
-		stream_handle);
+	context = alloc_stream_context(subject, FWU_STREAM_TYPE_INSTALL, stream_handle);
 
 	if (context) {
-
 		context->variant.install.fw_store = fw_store;
 		context->variant.install.installer = installer;
 		context->variant.install.image_info = image_info;
@@ -218,25 +187,19 @@
 	return status;
 }
 
-int stream_manager_close(
-	struct stream_manager *subject,
-	uint32_t handle,
-	bool accepted)
+int stream_manager_close(struct stream_manager *subject, uint32_t handle, bool accepted)
 {
 	int status = FWU_STATUS_UNKNOWN;
 	struct stream_context *context = get_active_context(subject, handle);
 
 	if (context) {
-
 		status = FWU_STATUS_SUCCESS;
 
 		if (context->type == FWU_STREAM_TYPE_INSTALL) {
-
-			status = fw_store_commit_image(
-				context->variant.install.fw_store,
-				context->variant.install.installer,
-				context->variant.install.image_info,
-				accepted);
+			status = fw_store_commit_image(context->variant.install.fw_store,
+						       context->variant.install.installer,
+						       context->variant.install.image_info,
+						       accepted);
 		}
 
 		free_stream_context(subject, context);
@@ -245,12 +208,9 @@
 	return status;
 }
 
-void stream_manager_cancel_streams(
-	struct stream_manager *subject,
-	enum fwu_stream_type type)
+void stream_manager_cancel_streams(struct stream_manager *subject, enum fwu_stream_type type)
 {
 	for (size_t i = 0; i < FWU_STREAM_MANAGER_POOL_SIZE; i++) {
-
 		struct stream_context *context = &subject->contexts[i];
 
 		if (context->type == type)
@@ -258,18 +218,14 @@
 	}
 }
 
-bool stream_manager_is_open_streams(
-	const struct stream_manager *subject,
-	enum fwu_stream_type type)
+bool stream_manager_is_open_streams(const struct stream_manager *subject, enum fwu_stream_type type)
 {
 	bool any_open = false;
 
 	for (size_t i = 0; i < FWU_STREAM_MANAGER_POOL_SIZE; i++) {
-
 		const struct stream_context *context = &subject->contexts[i];
 
 		if (context->type == type) {
-
 			any_open = true;
 			break;
 		}
@@ -278,45 +234,31 @@
 	return any_open;
 }
 
-int stream_manager_write(
-	struct stream_manager *subject,
-	uint32_t handle,
-	const uint8_t *data,
-	size_t data_len)
+int stream_manager_write(struct stream_manager *subject, uint32_t handle, const uint8_t *data,
+			 size_t data_len)
 {
 	int status = FWU_STATUS_UNKNOWN;
 	struct stream_context *context = get_active_context(subject, handle);
 
 	if (context && context->type == FWU_STREAM_TYPE_INSTALL) {
-
-		status = fw_store_write_image(
-			context->variant.install.fw_store,
-			context->variant.install.installer,
-			data, data_len);
+		status = fw_store_write_image(context->variant.install.fw_store,
+					      context->variant.install.installer, data, data_len);
 	}
 
 	return status;
 }
 
-int stream_manager_read(
-	struct stream_manager *subject,
-	uint32_t handle,
-	uint8_t *buf,
-	size_t buf_size,
-	size_t *read_len,
-	size_t *total_len)
+int stream_manager_read(struct stream_manager *subject, uint32_t handle, uint8_t *buf,
+			size_t buf_size, size_t *read_len, size_t *total_len)
 {
 	int status = FWU_STATUS_UNKNOWN;
 	struct stream_context *context = get_active_context(subject, handle);
 
 	if (context) {
-
 		if (context->type == FWU_STREAM_TYPE_BUFFER) {
-
 			size_t pos = context->variant.buffer.pos;
 			size_t remaining_len = context->variant.buffer.data_len - pos;
-			size_t len_to_read =
-				(remaining_len <= buf_size) ? remaining_len : buf_size;
+			size_t len_to_read = (remaining_len <= buf_size) ? remaining_len : buf_size;
 
 			memcpy(buf, &context->variant.buffer.data[pos], len_to_read);
 
@@ -326,7 +268,6 @@
 
 			status = FWU_STATUS_SUCCESS;
 		} else {
-
 			/* Reading from other types of stream is forbidden */
 			status = FWU_STATUS_DENIED;
 		}
diff --git a/components/service/fwu/agent/stream_manager.h b/components/service/fwu/agent/stream_manager.h
index 422080d..0ce534d 100644
--- a/components/service/fwu/agent/stream_manager.h
+++ b/components/service/fwu/agent/stream_manager.h
@@ -8,8 +8,8 @@
 #define FWU_STREAM_MANAGER_H
 
 #include <stdbool.h>
-#include <stdint.h>
 #include <stddef.h>
+#include <stdint.h>
 
 /**
  * Manages the set of streams used by the update_agent for image installation
@@ -35,17 +35,13 @@
  *  The default stream subject size
  */
 #ifndef FWU_STREAM_MANAGER_POOL_SIZE
-#define FWU_STREAM_MANAGER_POOL_SIZE        (4)
+#define FWU_STREAM_MANAGER_POOL_SIZE (4)
 #endif
 
 /**
  *  Identifier for the type of stream
  */
-enum fwu_stream_type {
-	FWU_STREAM_TYPE_NONE,
-	FWU_STREAM_TYPE_BUFFER,
-	FWU_STREAM_TYPE_INSTALL
-};
+enum fwu_stream_type { FWU_STREAM_TYPE_NONE, FWU_STREAM_TYPE_BUFFER, FWU_STREAM_TYPE_INSTALL };
 
 /**
  * A stream context
@@ -57,7 +53,6 @@
 	struct stream_context *prev;
 
 	union stream_variant {
-
 		/* Buffer stream variant */
 		struct buffer_variant {
 			size_t pos;
@@ -115,11 +110,8 @@
  *
  * \return FWU status
  */
-int stream_manager_open_buffer_stream(
-	struct stream_manager *subject,
-	const uint8_t *data,
-	size_t data_len,
-	uint32_t *stream_handle);
+int stream_manager_open_buffer_stream(struct stream_manager *subject, const uint8_t *data,
+				      size_t data_len, uint32_t *stream_handle);
 
 /**
  * \brief Open an install stream
@@ -135,12 +127,10 @@
  *
  * \return FWU status
  */
-int stream_manager_open_install_stream(
-	struct stream_manager *subject,
-	struct fw_store *fw_store,
-	struct installer *installer,
-	const struct image_info *image_info,
-	uint32_t *stream_handle);
+int stream_manager_open_install_stream(struct stream_manager *subject, struct fw_store *fw_store,
+				       struct installer *installer,
+				       const struct image_info *image_info,
+				       uint32_t *stream_handle);
 
 /**
  * \brief Close a previously opened stream
@@ -151,10 +141,7 @@
  *
  * \return FWU status
  */
-int stream_manager_close(
-	struct stream_manager *subject,
-	uint32_t stream_handle,
-	bool accepted);
+int stream_manager_close(struct stream_manager *subject, uint32_t stream_handle, bool accepted);
 
 /**
  * \brief Cancel all streams of the specified type
@@ -162,9 +149,7 @@
  * \param[in]  subject    The subject stream_manager
  * \param[in]  type       Type of stream to cancel
  */
-void stream_manager_cancel_streams(
-	struct stream_manager *subject,
-	enum fwu_stream_type type);
+void stream_manager_cancel_streams(struct stream_manager *subject, enum fwu_stream_type type);
 
 /**
  * \brief Check for any open streams of the specified type
@@ -174,9 +159,8 @@
  *
  * \return True is any are open
  */
-bool stream_manager_is_open_streams(
-	const struct stream_manager *subject,
-	enum fwu_stream_type type);
+bool stream_manager_is_open_streams(const struct stream_manager *subject,
+				    enum fwu_stream_type type);
 
 /**
  * \brief Write to a previously opened stream
@@ -188,11 +172,8 @@
  *
  * \return Status (0 on success)
  */
-int stream_manager_write(
-	struct stream_manager *subject,
-	uint32_t stream_handle,
-	const uint8_t *data,
-	size_t data_len);
+int stream_manager_write(struct stream_manager *subject, uint32_t stream_handle,
+			 const uint8_t *data, size_t data_len);
 
 /**
  * \brief Read from a previously opened stream
@@ -206,14 +187,8 @@
  *
  * \return Status (0 on success)
  */
-int stream_manager_read(
-	struct stream_manager *subject,
-	uint32_t handle,
-	uint8_t *buf,
-	size_t buf_size,
-	size_t *read_len,
-	size_t *total_len);
-
+int stream_manager_read(struct stream_manager *subject, uint32_t handle, uint8_t *buf,
+			size_t buf_size, size_t *read_len, size_t *total_len);
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/components/service/fwu/agent/update_agent.c b/components/service/fwu/agent/update_agent.c
index c54e9e5..2a4d19d 100644
--- a/components/service/fwu/agent/update_agent.c
+++ b/components/service/fwu/agent/update_agent.c
@@ -5,42 +5,30 @@
  *
  */
 
+#include "update_agent.h"
+
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
-#include <common/uuid/uuid.h>
-#include <protocols/service/fwu/packed-c/status.h>
-#include <protocols/service/fwu/packed-c/fwu_proto.h>
-#include <service/fwu/fw_store/fw_store.h>
-#include <service/fwu/inspector/fw_inspector.h>
+
+#include "common/uuid/uuid.h"
 #include "img_dir_serializer.h"
-#include "update_agent.h"
+#include "protocols/service/fwu/packed-c/fwu_proto.h"
+#include "protocols/service/fwu/packed-c/status.h"
+#include "service/fwu/fw_store/fw_store.h"
+#include "service/fwu/inspector/fw_inspector.h"
 
+static bool open_image_directory(struct update_agent *update_agent, const struct uuid_octets *uuid,
+				 uint32_t *handle, int *status);
 
-static bool open_image_directory(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle,
-	int *status);
+static bool open_fw_store_object(struct update_agent *update_agent, const struct uuid_octets *uuid,
+				 uint32_t *handle, int *status);
 
-static bool open_fw_store_object(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle,
-	int *status);
+static bool open_fw_image(struct update_agent *update_agent, const struct uuid_octets *uuid,
+			  uint32_t *handle, int *status);
 
-static bool open_fw_image(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle,
-	int *status);
-
-
-int update_agent_init(
-	struct update_agent *update_agent,
-	unsigned int boot_index,
-	fw_inspector_inspect fw_inspect_method,
-	struct fw_store *fw_store)
+int update_agent_init(struct update_agent *update_agent, unsigned int boot_index,
+		      fw_inspector_inspect fw_inspect_method, struct fw_store *fw_store)
 {
 	assert(update_agent);
 	assert(fw_inspect_method);
@@ -63,19 +51,15 @@
 	 */
 	fw_directory_init(&update_agent->fw_directory);
 
-	status = update_agent->fw_inspect_method(
-		&update_agent->fw_directory,
-		boot_index);
+	status = update_agent->fw_inspect_method(&update_agent->fw_directory, boot_index);
 	if (status != FWU_STATUS_SUCCESS)
 		return status;
 
 	/* Allow the associated fw_store to synchronize its state to the
 	 * state of the booted firmware reflected by the fw_directory.
 	 */
-	status = fw_store_synchronize(
-		update_agent->fw_store,
-		&update_agent->fw_directory,
-		boot_index);
+	status = fw_store_synchronize(update_agent->fw_store, &update_agent->fw_directory,
+				      boot_index);
 	if (status != FWU_STATUS_SUCCESS)
 		return status;
 
@@ -86,15 +70,13 @@
 		return FWU_STATUS_UNKNOWN;
 
 	/* Transition to initial state */
-	update_agent->state =
-		fw_store_is_trial(update_agent->fw_store) ?
-		FWU_STATE_TRIAL : FWU_STATE_REGULAR;
+	update_agent->state = fw_store_is_trial(update_agent->fw_store) ? FWU_STATE_TRIAL :
+									  FWU_STATE_REGULAR;
 
 	return FWU_STATUS_SUCCESS;
 }
 
-void update_agent_deinit(
-	struct update_agent *update_agent)
+void update_agent_deinit(struct update_agent *update_agent)
 {
 	update_agent->state = FWU_STATE_DEINITIALZED;
 
@@ -103,8 +85,7 @@
 	stream_manager_deinit(&update_agent->stream_manager);
 }
 
-int update_agent_begin_staging(
-	struct update_agent *update_agent)
+int update_agent_begin_staging(struct update_agent *update_agent)
 {
 	int status = FWU_STATUS_DENIED;
 
@@ -112,7 +93,6 @@
 	update_agent_cancel_staging(update_agent);
 
 	if (update_agent->state == FWU_STATE_REGULAR) {
-
 		status = fw_store_begin_install(update_agent->fw_store);
 
 		/* Check if ready to install images */
@@ -123,21 +103,18 @@
 	return status;
 }
 
-int update_agent_end_staging(
-	struct update_agent *update_agent)
+int update_agent_end_staging(struct update_agent *update_agent)
 {
 	int status = FWU_STATUS_DENIED;
 
 	if (update_agent->state == FWU_STATE_STAGING) {
-
 		/* The client is responsible for committing each installed image. If any
 		 * install streams have been left open, not all images were committed.
 		 */
-		bool any_uncommitted = stream_manager_is_open_streams(
-			&update_agent->stream_manager, FWU_STREAM_TYPE_INSTALL);
+		bool any_uncommitted = stream_manager_is_open_streams(&update_agent->stream_manager,
+								      FWU_STREAM_TYPE_INSTALL);
 
 		if (!any_uncommitted) {
-
 			/* All installed images have been committed so we're
 			 * ready for a trial.
 			 */
@@ -150,7 +127,6 @@
 				update_agent->state = FWU_STATE_TRIAL_PENDING;
 
 		} else {
-
 			/* Client failed to commit all images installed */
 			status = FWU_STATUS_BUSY;
 		}
@@ -159,15 +135,13 @@
 	return status;
 }
 
-int update_agent_cancel_staging(
-	struct update_agent *update_agent)
+int update_agent_cancel_staging(struct update_agent *update_agent)
 {
 	int status = FWU_STATUS_DENIED;
 
 	if (update_agent->state == FWU_STATE_STAGING) {
-
-		stream_manager_cancel_streams(
-			&update_agent->stream_manager, FWU_STREAM_TYPE_INSTALL);
+		stream_manager_cancel_streams(&update_agent->stream_manager,
+					      FWU_STREAM_TYPE_INSTALL);
 
 		fw_store_cancel_install(update_agent->fw_store);
 
@@ -179,23 +153,17 @@
 	return status;
 }
 
-int update_agent_accept(
-	struct update_agent *update_agent,
-	const struct uuid_octets *image_type_uuid)
+int update_agent_accept(struct update_agent *update_agent,
+			const struct uuid_octets *image_type_uuid)
 {
 	int status = FWU_STATUS_DENIED;
 
 	if (update_agent->state == FWU_STATE_TRIAL) {
-
-		const struct image_info *image_info = fw_directory_find_image_info(
-			&update_agent->fw_directory,
-			image_type_uuid);
+		const struct image_info *image_info =
+			fw_directory_find_image_info(&update_agent->fw_directory, image_type_uuid);
 
 		if (image_info) {
-
-			if (fw_store_notify_accepted(
-				update_agent->fw_store, image_info)) {
-
+			if (fw_store_notify_accepted(update_agent->fw_store, image_info)) {
 				/* From the fw_store perspective, the update has
 				 * been fully accepted.
 				 */
@@ -213,14 +181,12 @@
 	return status;
 }
 
-int update_agent_select_previous(
-	struct update_agent *update_agent)
+int update_agent_select_previous(struct update_agent *update_agent)
 {
 	int status = FWU_STATUS_DENIED;
 
 	if ((update_agent->state == FWU_STATE_TRIAL) ||
-		(update_agent->state == FWU_STATE_TRIAL_PENDING)) {
-
+	    (update_agent->state == FWU_STATE_TRIAL_PENDING)) {
 		status = fw_store_revert_to_previous(update_agent->fw_store);
 		update_agent->state = FWU_STATE_REGULAR;
 	}
@@ -228,18 +194,15 @@
 	return status;
 }
 
-int update_agent_open(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle)
+int update_agent_open(struct update_agent *update_agent, const struct uuid_octets *uuid,
+		      uint32_t *handle)
 {
 	int status;
 
 	/* Pass UUID along a chain-of-responsibility until it's handled */
 	if (!open_image_directory(update_agent, uuid, handle, &status) &&
-		!open_fw_store_object(update_agent, uuid, handle, &status) &&
-		!open_fw_image(update_agent, uuid, handle, &status)) {
-
+	    !open_fw_store_object(update_agent, uuid, handle, &status) &&
+	    !open_fw_image(update_agent, uuid, handle, &status)) {
 		/* UUID not recognised */
 		status = FWU_STATUS_UNKNOWN;
 	}
@@ -247,73 +210,45 @@
 	return status;
 }
 
-int update_agent_commit(
-	struct update_agent *update_agent,
-	uint32_t handle,
-	bool accepted)
+int update_agent_commit(struct update_agent *update_agent, uint32_t handle, bool accepted)
 {
-	return stream_manager_close(
-		&update_agent->stream_manager,
-		handle,
-		accepted);
+	return stream_manager_close(&update_agent->stream_manager, handle, accepted);
 }
 
-int update_agent_write_stream(
-	struct update_agent *update_agent,
-	uint32_t handle,
-	const uint8_t *data,
-	size_t data_len)
+int update_agent_write_stream(struct update_agent *update_agent, uint32_t handle,
+			      const uint8_t *data, size_t data_len)
 {
-	return stream_manager_write(
-		&update_agent->stream_manager,
-		handle,
-		data, data_len);
+	return stream_manager_write(&update_agent->stream_manager, handle, data, data_len);
 }
 
-int update_agent_read_stream(
-	struct update_agent *update_agent,
-	uint32_t handle,
-	uint8_t *buf,
-	size_t buf_size,
-	size_t *read_len,
-	size_t *total_len)
+int update_agent_read_stream(struct update_agent *update_agent, uint32_t handle, uint8_t *buf,
+			     size_t buf_size, size_t *read_len, size_t *total_len)
 {
-	return stream_manager_read(
-		&update_agent->stream_manager,
-		handle,
-		buf, buf_size,
-		read_len, total_len);
+	return stream_manager_read(&update_agent->stream_manager, handle, buf, buf_size, read_len,
+				   total_len);
 }
 
-static bool open_image_directory(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle,
-	int *status)
+static bool open_image_directory(struct update_agent *update_agent, const struct uuid_octets *uuid,
+				 uint32_t *handle, int *status)
 {
 	struct uuid_octets target_uuid;
 
 	uuid_guid_octets_from_canonical(&target_uuid, FWU_DIRECTORY_CANONICAL_UUID);
 
 	if (uuid_is_equal(uuid->octets, target_uuid.octets)) {
-
 		/* Serialize a fresh view of the image directory */
 		size_t serialized_len = 0;
 
-		*status = img_dir_serializer_serialize(
-			&update_agent->fw_directory,
-			update_agent->fw_store,
-			update_agent->image_dir_buf,
-			update_agent->image_dir_buf_size,
-			&serialized_len);
+		*status = img_dir_serializer_serialize(&update_agent->fw_directory,
+						       update_agent->fw_store,
+						       update_agent->image_dir_buf,
+						       update_agent->image_dir_buf_size,
+						       &serialized_len);
 
 		if (*status == FWU_STATUS_SUCCESS) {
-
-			*status = stream_manager_open_buffer_stream(
-				&update_agent->stream_manager,
-				update_agent->image_dir_buf,
-				serialized_len,
-				handle);
+			*status = stream_manager_open_buffer_stream(&update_agent->stream_manager,
+								    update_agent->image_dir_buf,
+								    serialized_len, handle);
 		}
 
 		return true;
@@ -322,28 +257,18 @@
 	return false;
 }
 
-static bool open_fw_store_object(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle,
-	int *status)
+static bool open_fw_store_object(struct update_agent *update_agent, const struct uuid_octets *uuid,
+				 uint32_t *handle, int *status)
 {
 	const uint8_t *exported_data;
 	size_t exported_data_len;
 
-	if (fw_store_export(
-			update_agent->fw_store,
-			uuid,
-			&exported_data, &exported_data_len,
-			status)) {
-
+	if (fw_store_export(update_agent->fw_store, uuid, &exported_data, &exported_data_len,
+			    status)) {
 		if (*status == FWU_STATUS_SUCCESS) {
-
-			*status = stream_manager_open_buffer_stream(
-				&update_agent->stream_manager,
-				exported_data,
-				exported_data_len,
-				handle);
+			*status = stream_manager_open_buffer_stream(&update_agent->stream_manager,
+								    exported_data,
+								    exported_data_len, handle);
 		}
 
 		return true;
@@ -352,38 +277,25 @@
 	return false;
 }
 
-static bool open_fw_image(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle,
-	int *status)
+static bool open_fw_image(struct update_agent *update_agent, const struct uuid_octets *uuid,
+			  uint32_t *handle, int *status)
 {
-	const struct image_info *image_info = fw_directory_find_image_info(
-		&update_agent->fw_directory,
-		uuid);
+	const struct image_info *image_info =
+		fw_directory_find_image_info(&update_agent->fw_directory, uuid);
 
 	if (image_info) {
-
 		if (update_agent->state == FWU_STATE_STAGING) {
-
 			struct installer *installer;
 
-			*status = fw_store_select_installer(
-				update_agent->fw_store,
-				image_info,
-				&installer);
+			*status = fw_store_select_installer(update_agent->fw_store, image_info,
+							    &installer);
 
 			if (*status == FWU_STATUS_SUCCESS) {
-
 				*status = stream_manager_open_install_stream(
-					&update_agent->stream_manager,
-					update_agent->fw_store,
-					installer,
-					image_info,
-					handle);
+					&update_agent->stream_manager, update_agent->fw_store,
+					installer, image_info, handle);
 			}
 		} else {
-
 			/* Attempting to open a fw image when not staging */
 			*status = FWU_STATUS_DENIED;
 		}
diff --git a/components/service/fwu/agent/update_agent.h b/components/service/fwu/agent/update_agent.h
index 274e71a..ea214ee 100644
--- a/components/service/fwu/agent/update_agent.h
+++ b/components/service/fwu/agent/update_agent.h
@@ -10,9 +10,10 @@
 
 #include <stdbool.h>
 #include <stdint.h>
-#include <common/uuid/uuid.h>
-#include <service/fwu/inspector/fw_inspector.h>
+
+#include "common/uuid/uuid.h"
 #include "fw_directory.h"
+#include "service/fwu/inspector/fw_inspector.h"
 #include "stream_manager.h"
 
 #ifdef __cplusplus
@@ -67,19 +68,15 @@
  *
  * \return Status (0 for success).  Uses fwu protocol status codes.
  */
-int update_agent_init(
-	struct update_agent *update_agent,
-	unsigned int boot_index,
-	fw_inspector_inspect fw_inspect_method,
-	struct fw_store *fw_store);
+int update_agent_init(struct update_agent *update_agent, unsigned int boot_index,
+		      fw_inspector_inspect fw_inspect_method, struct fw_store *fw_store);
 
 /**
  * \brief De-initialise the update_agent
  *
  * \param[in]  update_agent    The subject update_agent
  */
-void update_agent_deinit(
-	struct update_agent *update_agent);
+void update_agent_deinit(struct update_agent *update_agent);
 
 /**
  * \brief Begin staging
@@ -88,8 +85,7 @@
  *
  * \return 0 on successfully transitioning to the STAGING state
  */
-int update_agent_begin_staging(
-	struct update_agent *update_agent);
+int update_agent_begin_staging(struct update_agent *update_agent);
 
 /**
  * \brief End staging
@@ -98,8 +94,7 @@
  *
  * \return 0 on successfully transitioning to the TRIAL state
  */
-int update_agent_end_staging(
-	struct update_agent *update_agent);
+int update_agent_end_staging(struct update_agent *update_agent);
 
 /**
  * \brief Cancel staging
@@ -108,8 +103,7 @@
  *
  * \return 0 on successfully transitioning to the REGULAR state
  */
-int update_agent_cancel_staging(
-	struct update_agent *update_agent);
+int update_agent_cancel_staging(struct update_agent *update_agent);
 
 /**
  * \brief Accept an updated image
@@ -119,9 +113,8 @@
  *
  * \return Status (0 on success)
  */
-int update_agent_accept(
-	struct update_agent *update_agent,
-	const struct uuid_octets *image_type_uuid);
+int update_agent_accept(struct update_agent *update_agent,
+			const struct uuid_octets *image_type_uuid);
 
 /**
  * \brief Select previous version
@@ -132,8 +125,7 @@
  *
  * \return Status (0 on success)
  */
-int update_agent_select_previous(
-	struct update_agent *update_agent);
+int update_agent_select_previous(struct update_agent *update_agent);
 
 /**
  * \brief Open a stream for accessing an fwu stream
@@ -147,10 +139,8 @@
  *
  * \return Status (0 on success)
  */
-int update_agent_open(
-	struct update_agent *update_agent,
-	const struct uuid_octets *uuid,
-	uint32_t *handle);
+int update_agent_open(struct update_agent *update_agent, const struct uuid_octets *uuid,
+		      uint32_t *handle);
 
 /**
  * \brief Close a stream and commit any writes to the stream
@@ -161,10 +151,7 @@
  *
  * \return Status (0 on success)
  */
-int update_agent_commit(
-	struct update_agent *update_agent,
-	uint32_t handle,
-	bool accepted);
+int update_agent_commit(struct update_agent *update_agent, uint32_t handle, bool accepted);
 
 /**
  * \brief Write to a previously opened stream
@@ -176,11 +163,8 @@
  *
  * \return Status (0 on success)
  */
-int update_agent_write_stream(
-	struct update_agent *update_agent,
-	uint32_t handle,
-	const uint8_t *data,
-	size_t data_len);
+int update_agent_write_stream(struct update_agent *update_agent, uint32_t handle,
+			      const uint8_t *data, size_t data_len);
 
 /**
  * \brief Read from a previously opened stream
@@ -194,14 +178,8 @@
  *
  * \return Status (0 on success)
  */
-int update_agent_read_stream(
-	struct update_agent *update_agent,
-	uint32_t handle,
-	uint8_t *buf,
-	size_t buf_size,
-	size_t *read_len,
-	size_t *total_len);
-
+int update_agent_read_stream(struct update_agent *update_agent, uint32_t handle, uint8_t *buf,
+			     size_t buf_size, size_t *read_len, size_t *total_len);
 
 #ifdef __cplusplus
 }