Fix MISRA defects in PMF
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Thu, 25 Oct 2018 16:38:23 +0000 (17:38 +0100)
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Mon, 29 Oct 2018 14:42:39 +0000 (14:42 +0000)
No functional changes.

Change-Id: I64abd72026082218a40b1a4b8f7dc26ff2478ba6
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
include/lib/pmf/pmf.h
include/lib/pmf/pmf_helpers.h
lib/pmf/pmf_main.c
lib/pmf/pmf_smc.c

index a3812fbf2deb4317dc2bad6eb08e59e9c3a2e575..18ef0a5598ea87ad1c8ae058416063b826b5b1e9 100644 (file)
@@ -9,17 +9,18 @@
 
 #include <cassert.h>
 #include <pmf_helpers.h>
+#include <utils_def.h>
 
 /*
  * Constants used for/by PMF services.
  */
-#define PMF_ARM_TIF_IMPL_ID    0x41
+#define PMF_ARM_TIF_IMPL_ID    U(0x41)
 #define PMF_TID_SHIFT          0
-#define PMF_TID_MASK           (0xFF << PMF_TID_SHIFT)
+#define PMF_TID_MASK           (U(0xFF) << PMF_TID_SHIFT)
 #define PMF_SVC_ID_SHIFT       10
-#define PMF_SVC_ID_MASK                (0x3F << PMF_SVC_ID_SHIFT)
+#define PMF_SVC_ID_MASK                (U(0x3F) << PMF_SVC_ID_SHIFT)
 #define PMF_IMPL_ID_SHIFT      24
-#define PMF_IMPL_ID_MASK       (0xFFU << PMF_IMPL_ID_SHIFT)
+#define PMF_IMPL_ID_MASK       (U(0xFF) << PMF_IMPL_ID_SHIFT)
 
 /*
  * Flags passed to PMF_REGISTER_SERVICE
 /*
  * Defines for PMF SMC function ids.
  */
-#define PMF_SMC_GET_TIMESTAMP_32       0x82000010u
-#define PMF_SMC_GET_TIMESTAMP_64       0xC2000010u
+#define PMF_SMC_GET_TIMESTAMP_32       U(0x82000010)
+#define PMF_SMC_GET_TIMESTAMP_64       U(0xC2000010)
 #define PMF_NUM_SMC_CALLS              2
 
 /*
  * The macros below are used to identify
  * PMF calls from the SMC function ID.
  */
-#define PMF_FID_MASK   0xffe0u
-#define PMF_FID_VALUE  0u
+#define PMF_FID_MASK   U(0xffe0)
+#define PMF_FID_VALUE  U(0)
 #define is_pmf_fid(_fid)       (((_fid) & PMF_FID_MASK) == PMF_FID_VALUE)
 
 /* Following are the supported PMF service IDs */
index b9757de072a271fa77c608a5b64b86afa98e9705..c535b222d3eece64fc73e4a830be6a85c5082a83 100644 (file)
@@ -11,7 +11,6 @@
 #include <assert.h>
 #include <bl_common.h>
 #include <platform.h>
-#include <pmf.h>
 #include <stddef.h>
 #include <stdint.h>
 
index 25513c1915ff75114762c5462232c8af4f6ced71..fe7bb7423b75dc43d53d69efc59bf0c379d460b5 100644 (file)
@@ -26,7 +26,7 @@
 IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_START__,         PMF_SVC_DESCS_START);
 IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_END__,           PMF_SVC_DESCS_END);
 IMPORT_SYM(uintptr_t, __PMF_PERCPU_TIMESTAMP_END__,    PMF_PERCPU_TIMESTAMP_END);
-IMPORT_SYM(intptr_t,  __PMF_TIMESTAMP_START__,         PMF_TIMESTAMP_ARRAY_START);
+IMPORT_SYM(uintptr_t,  __PMF_TIMESTAMP_START__,                PMF_TIMESTAMP_ARRAY_START);
 
 #define PMF_PERCPU_TIMESTAMP_SIZE      (PMF_PERCPU_TIMESTAMP_END - PMF_TIMESTAMP_ARRAY_START)
 
@@ -67,15 +67,15 @@ int pmf_setup(void)
        pmf_svc_descs = (pmf_svc_desc_t *) PMF_SVC_DESCS_START;
        for (ii = 0; ii < pmf_svc_descs_num; ii++) {
 
-               assert(pmf_svc_descs[ii].get_ts);
+               assert(pmf_svc_descs[ii].get_ts != NULL);
 
                /*
                 * Call the initialization routine for this
                 * PMF service, if it is defined.
                 */
-               if (pmf_svc_descs[ii].init) {
+               if (pmf_svc_descs[ii].init != NULL) {
                        rc = pmf_svc_descs[ii].init();
-                       if (rc) {
+                       if (rc != 0) {
                                WARN("Could not initialize PMF"
                                        "service %s - skipping \n",
                                        pmf_svc_descs[ii].name);
@@ -125,7 +125,7 @@ static pmf_svc_desc_t *get_service(unsigned int tid)
        if (pmf_num_services == 0)
                return NULL;
 
-       assert(pmf_svc_descs);
+       assert(pmf_svc_descs != NULL);
 
        do {
                mid = (low + high) / 2;
@@ -158,7 +158,7 @@ int pmf_get_timestamp_smc(unsigned int tid,
                unsigned long long *ts_value)
 {
        pmf_svc_desc_t *svc_desc;
-       assert(ts_value);
+       assert(ts_value != NULL);
 
        /* Search for registered service. */
        svc_desc = get_service(tid);
@@ -247,7 +247,7 @@ unsigned long long __pmf_get_timestamp(uintptr_t base_addr,
        unsigned long long *ts_addr = (unsigned long long *)calc_ts_addr(base_addr,
                                tid, cpuid);
 
-       if (flags & PMF_CACHE_MAINT)
+       if ((flags & PMF_CACHE_MAINT) != 0U)
                inv_dcache_range((uintptr_t)ts_addr, sizeof(unsigned long long));
 
        return *ts_addr;
index e86611802b43601b7094ac6c216dc12366f17238..4c5b14f93bd66fd4106eeb5775e4a8ba2a1eb600 100644 (file)
@@ -37,7 +37,8 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
                         * x0 --> error code.
                         * x1 - x2 --> time-stamp value.
                         */
-                       rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value);
+                       rc = pmf_get_timestamp_smc((unsigned int)x1, x2,
+                                       (unsigned int)x3, &ts_value);
                        SMC_RET3(handle, rc, (uint32_t)ts_value,
                                        (uint32_t)(ts_value >> 32));
                }
@@ -49,7 +50,8 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
                         * x0 --> error code.
                         * x1 --> time-stamp value.
                         */
-                       rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value);
+                       rc = pmf_get_timestamp_smc((unsigned int)x1, x2,
+                                       (unsigned int)x3, &ts_value);
                        SMC_RET2(handle, rc, ts_value);
                }
        }