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/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);