chore: fix `clang-tidy` warnings

Fix warnings introduced by previous commit.

Change-Id: I3884f8a774860905ddf3d4554f986fde16ec9919
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/inc/hf/addr.h b/inc/hf/addr.h
index 45d7b37..876b6ee 100644
--- a/inc/hf/addr.h
+++ b/inc/hf/addr.h
@@ -166,6 +166,7 @@
  */
 static inline void *ptr_from_va(vaddr_t va)
 {
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (void *)va_addr(va);
 }
 
diff --git a/inc/hf/api.h b/inc/hf/api.h
index fe4593e..7be3ed7 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -67,15 +67,15 @@
 				 uint32_t requested_version);
 struct ffa_value api_ffa_partition_info_get(struct vcpu *current,
 					    const struct ffa_uuid *uuid,
-					    const uint32_t flags);
+					    uint32_t flags);
 bool api_ffa_fill_partition_info_from_regs(
 	struct ffa_value ret, uint16_t start_index,
 	struct ffa_partition_info *partitions, uint16_t partitions_len,
 	ffa_vm_count_t *ret_count);
 struct ffa_value api_ffa_partition_info_get_regs(struct vcpu *current,
 						 const struct ffa_uuid *uuid,
-						 const uint16_t start_index,
-						 const uint16_t tag);
+						 uint16_t start_index,
+						 uint16_t tag);
 struct ffa_value api_ffa_id_get(const struct vcpu *current);
 struct ffa_value api_ffa_spm_id_get(void);
 struct ffa_value api_ffa_feature_success(uint32_t arg2);
@@ -156,7 +156,7 @@
 				      uint32_t mem_perm, struct vcpu *current);
 
 void api_flush_log_buffer(struct vcpu_locked *vcpu_locked);
-struct ffa_value api_ffa_console_log(const struct ffa_value args,
+struct ffa_value api_ffa_console_log(struct ffa_value args,
 				     struct vcpu *current);
 
 void api_ffa_resume_direct_resp_target(struct vcpu_locked current_locked,
diff --git a/inc/hf/arch/cpu.h b/inc/hf/arch/cpu.h
index 20052cd..096ebca 100644
--- a/inc/hf/arch/cpu.h
+++ b/inc/hf/arch/cpu.h
@@ -38,13 +38,13 @@
  * Verifies the `gp_reg_num` complies with the number of registers available in
  * the architecture.
  */
-bool arch_regs_reg_num_valid(const uint32_t gp_reg_num);
+bool arch_regs_reg_num_valid(uint32_t gp_reg_num);
 
 /**
  * Sets the value of a general purpose register.
  */
 void arch_regs_set_gp_reg(struct arch_regs *r, uintreg_t value,
-			  const uint32_t gp_reg_num);
+			  uint32_t gp_reg_num);
 
 /**
  * Updates the register holding the return value of a function.
diff --git a/inc/hf/arch/plat/ffa.h b/inc/hf/arch/plat/ffa.h
index 35aa159..d2b0836 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -199,7 +199,7 @@
 bool plat_ffa_vm_notifications_info_get(uint16_t *ids, uint32_t *ids_count,
 					uint32_t *lists_sizes,
 					uint32_t *lists_count,
-					const uint32_t ids_count_max);
+					uint32_t ids_count_max);
 
 /** Helper to set SRI current state. */
 void plat_ffa_sri_state_set(enum plat_ffa_sri_state state);
@@ -226,7 +226,7 @@
 void plat_ffa_notification_info_get_forward(uint16_t *ids, uint32_t *ids_count,
 					    uint32_t *lists_sizes,
 					    uint32_t *lists_count,
-					    const uint32_t ids_count_max);
+					    uint32_t ids_count_max);
 
 bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current);
 bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current);
@@ -255,7 +255,7 @@
 bool plat_ffa_partition_info_get_regs_forward_allowed(void);
 
 void plat_ffa_partition_info_get_forward(const struct ffa_uuid *uuid,
-					 const uint32_t flags,
+					 uint32_t flags,
 					 struct ffa_partition_info *partitions,
 					 ffa_vm_count_t *ret_count);
 
diff --git a/inc/hf/arch/std.h b/inc/hf/arch/std.h
index 91f808e..d1c8b7a 100644
--- a/inc/hf/arch/std.h
+++ b/inc/hf/arch/std.h
@@ -13,8 +13,10 @@
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
 int memcmp(const void *a, const void *b, size_t n);
 
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
 int strncmp(const char *a, const char *b, size_t n);
 
 #define ctz(x) __builtin_ctz(x)
diff --git a/inc/hf/cpu.h b/inc/hf/cpu.h
index 305f2f8..a80431d 100644
--- a/inc/hf/cpu.h
+++ b/inc/hf/cpu.h
@@ -10,11 +10,12 @@
 
 #define STACK_SIZE (8192)
 
-#if !defined(__ASSEMBLER__)
+#ifndef __ASSEMBLER__
 
 #include "hf/arch/cpu.h"
 
 /* TODO: Fix alignment such that `cpu` structs are in different cache lines. */
+/* NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding) */
 struct cpu {
 	/** CPU identifier. Doesn't have to be contiguous. */
 	cpu_id_t id;
diff --git a/inc/hf/io.h b/inc/hf/io.h
index 7bab385..06391ef 100644
--- a/inc/hf/io.h
+++ b/inc/hf/io.h
@@ -58,6 +58,7 @@
 
 static inline io8_t io8_c(uintpaddr_t addr, uintpaddr_t offset)
 {
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io8_t){.ptr = (volatile uint8_t *)(addr + offset)};
 }
 
@@ -66,11 +67,13 @@
 {
 	(void)offset;
 
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io8_array_t){.base = (volatile uint8_t *)addr, .count = count};
 }
 
 static inline io16_t io16_c(uintpaddr_t addr, uintpaddr_t offset)
 {
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io16_t){.ptr = (volatile uint16_t *)(addr + offset)};
 }
 
@@ -79,12 +82,14 @@
 {
 	(void)offset;
 
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io16_array_t){.base = (volatile uint16_t *)addr,
 			      .count = count};
 }
 
 static inline io32_t io32_c(uintpaddr_t addr, uintpaddr_t offset)
 {
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io32_t){.ptr = (volatile uint32_t *)(addr + offset)};
 }
 
@@ -93,12 +98,14 @@
 {
 	(void)offset;
 
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io32_array_t){.base = (volatile uint32_t *)addr,
 			      .count = count};
 }
 
 static inline io64_t io64_c(uintpaddr_t addr, uintpaddr_t offset)
 {
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io64_t){.ptr = (volatile uint64_t *)(addr + offset)};
 }
 
@@ -107,6 +114,7 @@
 {
 	(void)offset;
 
+	/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
 	return (io64_array_t){.base = (volatile uint64_t *)addr,
 			      .count = count};
 }
diff --git a/inc/hf/list.h b/inc/hf/list.h
index 1f13697..e5791c7 100644
--- a/inc/hf/list.h
+++ b/inc/hf/list.h
@@ -16,9 +16,10 @@
 	struct list_entry *prev;
 };
 
-#define LIST_INIT(l) {.next = &l, .prev = &l}
+#define LIST_INIT(l) {.next = &(l), .prev = &(l)}
+
 #define CONTAINER_OF(ptr, type, field) \
-	((type *)((char *)ptr - offsetof(type, field)))
+	((type *)((char *)(ptr) - offsetof(type, field)))
 
 static inline void list_init(struct list_entry *e)
 {
diff --git a/inc/hf/offset_size_header.h b/inc/hf/offset_size_header.h
index 6fcf558..7182dd8 100644
--- a/inc/hf/offset_size_header.h
+++ b/inc/hf/offset_size_header.h
@@ -54,14 +54,14 @@
 #define DEFINE_SIZEOF(sym, type)                                 \
 	void gen_header__##sym(void)                             \
 	{                                                        \
-		static_assert(sizeof(type) == sym,               \
+		static_assert(sizeof(type) == (sym),             \
 			      "Generated struct size mismatch"); \
 	}
 
 #define DEFINE_OFFSETOF(sym, type, field)                          \
 	void gen_header__##sym(void)                               \
 	{                                                          \
-		static_assert(offsetof(type, field) == sym,        \
+		static_assert(offsetof(type, field) == (sym),      \
 			      "Generated struct offset mismatch"); \
 	}
 
diff --git a/inc/hf/sp_pkg.h b/inc/hf/sp_pkg.h
index 182840a..3eb2b90 100644
--- a/inc/hf/sp_pkg.h
+++ b/inc/hf/sp_pkg.h
@@ -39,7 +39,7 @@
 static inline size_t sp_pkg_get_mem_size(struct sp_pkg_header *sp_pkg)
 {
 	assert(SIZE_MAX - sp_pkg->img_offset >= (size_t)sp_pkg->img_size);
-	return (size_t)(sp_pkg->img_offset + sp_pkg->img_size);
+	return (sp_pkg->img_offset + sp_pkg->img_size);
 }
 
 /** Get the size of the boot information descriptors section. */
diff --git a/inc/hf/std.h b/inc/hf/std.h
index ca540e1..5b87eb9 100644
--- a/inc/hf/std.h
+++ b/inc/hf/std.h
@@ -10,8 +10,8 @@
 
 #include "hf/arch/std.h"
 
-#define MAX(x, y) (x > y ? x : y)
-#define MIN(x, y) (x < y ? x : y)
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
 
 typedef size_t rsize_t;
 
@@ -29,10 +29,15 @@
  * These functions don't return errno_t as per the specification and implicitly
  * have a constraint handler that panics.
  */
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
 void memset_s(void *dest, rsize_t destsz, int ch, rsize_t count);
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
 void memcpy_s(void *dest, rsize_t destsz, const void *src, rsize_t count);
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
 void memmove_s(void *dest, rsize_t destsz, const void *src, rsize_t count);
 
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
 void *memchr(const void *ptr, int ch, size_t count);
 
+/* NOLINTNEXTLINE(readability-redundant-declaration) */
 size_t strnlen_s(const char *str, size_t strsz);
diff --git a/inc/hf/string.h b/inc/hf/string.h
index 35f669b..9d771e6 100644
--- a/inc/hf/string.h
+++ b/inc/hf/string.h
@@ -40,7 +40,7 @@
  * Macro to initialize `struct string` from a string constant.
  * Triggers a compilation error if the string does not fit into the buffer.
  */
-#define STRING_INIT(str) ((struct string){.data = str})
+#define STRING_INIT(str) ((struct string){.data = (str)})
 
 enum string_return_code string_init(struct string *str,
 				    const struct memiter *data);
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index affae37..0e8ac47 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -198,6 +198,7 @@
 	bool permissive;
 };
 
+/* NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding) */
 struct vm {
 	ffa_id_t id;
 	struct ffa_uuid uuids[PARTITION_MAX_UUIDS];
@@ -382,14 +383,13 @@
 void vm_notifications_info_get_pending(
 	struct vm_locked vm_locked, bool is_from_vm, uint16_t *ids,
 	uint32_t *ids_count, uint32_t *lists_sizes, uint32_t *lists_count,
-	const uint32_t ids_max_count,
+	uint32_t ids_max_count,
 	enum notifications_info_get_state *info_get_state);
 bool vm_notifications_pending_not_retrieved_by_scheduler(void);
 bool vm_is_notifications_pending_count_zero(void);
 bool vm_notifications_info_get(struct vm_locked vm_locked, uint16_t *ids,
 			       uint32_t *ids_count, uint32_t *lists_sizes,
-			       uint32_t *lists_count,
-			       const uint32_t ids_max_count);
+			       uint32_t *lists_count, uint32_t ids_max_count);
 bool vm_supports_messaging_method(struct vm *vm, uint16_t messaging_method);
 void vm_notifications_set_npi_injected(struct vm_locked vm_locked,
 				       bool npi_injected);