Interface: Improve code quality

This patch fixes the following things:
* avoid implicit casting by using matching types or casting when it is
safe
* initialise unitialised variables
* check the returning value of functions

Change-Id: I0fda9b6d3ba9dbc86654685736a37a60f5db9a75
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
diff --git a/interface/include/tfm_ns_lock.h b/interface/include/tfm_ns_lock.h
index 0c73a60..d3cf055 100644
--- a/interface/include/tfm_ns_lock.h
+++ b/interface/include/tfm_ns_lock.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -32,7 +32,7 @@
  * \details Needs to be called during non-secure app init
  *          to initialize the TFM NS lock object
  */
-uint32_t tfm_ns_lock_init();
+enum tfm_status_e tfm_ns_lock_init();
 
 #ifdef __cplusplus
 }
diff --git a/interface/include/tfm_ns_svc.h b/interface/include/tfm_ns_svc.h
index 0399af9..a45cd97 100644
--- a/interface/include/tfm_ns_svc.h
+++ b/interface/include/tfm_ns_svc.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -59,7 +59,7 @@
 };
 
 /* number of user SVC functions */
-#define USER_SVC_COUNT (SVC_TFM_MAX - 1)
+#define USER_SVC_COUNT ((uint32_t)SVC_TFM_MAX - 1)
 
 #ifdef __cplusplus
 }
diff --git a/interface/src/tfm_ns_lock_rtx.c b/interface/src/tfm_ns_lock_rtx.c
index 59ef149..14fd76a 100644
--- a/interface/src/tfm_ns_lock_rtx.c
+++ b/interface/src/tfm_ns_lock_rtx.c
@@ -31,7 +31,9 @@
  */
 static const osMutexAttr_t ns_lock_attrib = {
     .name = "ns_lock",
-    .attr_bits = osMutexPrioInherit
+    .attr_bits = osMutexPrioInherit,
+    .cb_mem = NULL,
+    .cb_size = 0U
 };
 
 /**
@@ -49,11 +51,15 @@
     }
 
     /* TFM request protected by NS lock */
-    osMutexAcquire(ns_lock.id,osWaitForever);
+    if (osMutexAcquire(ns_lock.id,osWaitForever) != osOK) {
+        return TFM_ERROR_GENERIC;
+    }
 
     result = fn(arg0, arg1, arg2, arg3);
 
-    osMutexRelease(ns_lock.id);
+    if (osMutexRelease(ns_lock.id) != osOK) {
+        return TFM_ERROR_GENERIC;
+    }
 
     return result;
 }
@@ -61,7 +67,7 @@
 /**
  * \brief NS world, Init NS lock
  */
-uint32_t tfm_ns_lock_init()
+enum tfm_status_e tfm_ns_lock_init()
 {
     if (ns_lock.init == false) {
         ns_lock.id = osMutexNew(&ns_lock_attrib);