service: fix return values of functions to 0 or 1
authorHarry van Haaren <harry.van.haaren@intel.com>
Mon, 21 Aug 2017 12:58:11 +0000 (13:58 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 15 Sep 2017 11:46:43 +0000 (13:46 +0200)
Previously to this commit, the return value of the following
functions was the mask value, instead of a neat 0 or 1.

This commit fixes this using the "!!" trick, to force the
number to 1 instead of the bitmask value itself, bringing
the return value in line with the function documentation.

Fixes: 21698354c832 ("service: introduce service cores concept")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
lib/librte_eal/common/rte_service.c

index 36f9213..6967ea3 100644 (file)
@@ -163,7 +163,7 @@ service_stats_enabled(struct rte_service_spec_impl *impl)
 static inline int
 service_mt_safe(struct rte_service_spec_impl *s)
 {
-       return s->spec.capabilities & RTE_SERVICE_CAP_MT_SAFE;
+       return !!(s->spec.capabilities & RTE_SERVICE_CAP_MT_SAFE);
 }
 
 int32_t rte_service_set_stats_enable(uint32_t id, int32_t enabled)
@@ -215,7 +215,7 @@ rte_service_probe_capability(uint32_t id, uint32_t capability)
 {
        struct rte_service_spec_impl *s;
        SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);
-       return s->spec.capabilities & capability;
+       return !!(s->spec.capabilities & capability);
 }
 
 int32_t
@@ -476,7 +476,7 @@ service_update(struct rte_service_spec *service, uint32_t lcore,
        }
 
        if (enabled)
-               *enabled = (lcore_states[lcore].service_mask & (sid_mask));
+               *enabled = !!(lcore_states[lcore].service_mask & (sid_mask));
 
        rte_smp_wmb();