Fix -Werror related build issues

The release build triggers unused variable warnings due to asserts
being removed. Change affected code to remove the warnings.
For projects depending on the TF-A external component define the
TF-A specific ENABLE_ASSERTIONS=0 macro to avoid warnings in TF-A
source files.

Signed-off-by: Gabor Toth <gabor.toth2@arm.com>
Change-Id: Idf861bb1c7b1f90fc3a0d10aa59ea1e5943ea49a
diff --git a/components/common/uuid/uuid.c b/components/common/uuid/uuid.c
index 16b6730..85ac216 100644
--- a/components/common/uuid/uuid.c
+++ b/components/common/uuid/uuid.c
@@ -8,6 +8,7 @@
 #include <assert.h>
 #include <string.h>
 #include <ctype.h>
+#include <compiler.h>
 
 static uint8_t hex_to_nibble(char hex)
 {
@@ -189,7 +190,7 @@
 void uuid_octets_from_canonical(struct uuid_octets *uuid_octets,
 	const char *canonical_form)
 {
-	size_t valid_chars = uuid_parse_to_octets(canonical_form,
+	__maybe_unused size_t valid_chars = uuid_parse_to_octets(canonical_form,
 		uuid_octets->octets, sizeof(uuid_octets->octets));
 
 	/* Input string is assumed to be valid. Should not be used if canonical
@@ -201,7 +202,7 @@
 void uuid_guid_octets_from_canonical(struct uuid_octets *uuid_octets,
 	const char *canonical_form)
 {
-	size_t valid_chars = uuid_parse_to_guid_octets(canonical_form,
+	__maybe_unused size_t valid_chars = uuid_parse_to_guid_octets(canonical_form,
 		uuid_octets->octets, sizeof(uuid_octets->octets));
 
 	assert(valid_chars == UUID_CANONICAL_FORM_LEN);
diff --git a/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp b/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp
index edad9df..d17550d 100644
--- a/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp
+++ b/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp
@@ -10,6 +10,7 @@
 #include "service/secure_storage/frontend/secure_storage_provider/secure_storage_uuid.h"
 #include "media/disk/guid.h"
 #include <assert.h>
+#include <compiler.h>
 
 ps_service_context::ps_service_context(const char *sn) :
 	standalone_service_context(sn),
@@ -37,7 +38,7 @@
 	m_block_store = client_block_store_factory_create("sn:trustedfirmware.org:block-storage:0");
 	assert(m_block_store != NULL);
 
-	psa_status_t status = sfs_flash_block_store_adapter_init(
+	__maybe_unused psa_status_t status = sfs_flash_block_store_adapter_init(
 		&m_sfs_flash_adapter,
 		0,
 		m_block_store,
diff --git a/external/tf_a/tf-a.cmake b/external/tf_a/tf-a.cmake
index a7a28f8..6a2d2ad 100644
--- a/external/tf_a/tf-a.cmake
+++ b/external/tf_a/tf-a.cmake
@@ -59,4 +59,10 @@
 	target_include_directories(${MY_PARAMS_TARGET} PRIVATE "${TFA_SOURCE_DIR}/include")
 	target_include_directories(${MY_PARAMS_TARGET} PRIVATE "${TFA_SOURCE_DIR}/include/arch/aarch64")
 
+	# Disable assertions in TF-A for release builds
+	if ("${UC_CMAKE_BUILD_TYPE}" STREQUAL "MINSIZEREL" OR
+		"${UC_CMAKE_BUILD_TYPE}" STREQUAL "RELEASE" OR
+		"${UC_CMAKE_BUILD_TYPE}" STREQUAL "RELWITHDEBINFO")
+    	target_compile_definitions(${MY_PARAMS_TARGET} PRIVATE "ENABLE_ASSERTIONS=0")
+	endif()
 endfunction()
\ No newline at end of file