summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/msg/src/msg_drv.c2
-rw-r--r--cesar/lib/utils.h11
2 files changed, 12 insertions, 1 deletions
diff --git a/cesar/cp/msg/src/msg_drv.c b/cesar/cp/msg/src/msg_drv.c
index bbfd3523bf..bf4cfc9e1b 100644
--- a/cesar/cp/msg/src/msg_drv.c
+++ b/cesar/cp/msg/src/msg_drv.c
@@ -328,7 +328,7 @@ cp_msg_drv_sta_set_tonemask_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
/* Check last carriers are unused. */
if (PHY_CARRIER_NB % 32)
{
- w = tonemask[-1] | BITS_ONES (PHY_CARRIER_NB % 32);
+ w = tonemask[-1] | BITS_ONES_OR_ZERO (PHY_CARRIER_NB % 32);
if (w != ~0u)
return false;
}
diff --git a/cesar/lib/utils.h b/cesar/lib/utils.h
index 306030ffff..c88c7fd03b 100644
--- a/cesar/lib/utils.h
+++ b/cesar/lib/utils.h
@@ -134,6 +134,17 @@ lesseq_mod2p16 (u16 a, u16 b)
*/
#define BITS_ONES(b) ((1u << ((b) - 1) << 1) - 1)
+/** Return a bit mask composed of a number of LSB ones.
+ * \param b number of one bits, 0 to 32
+ *
+ * - BITS_ONES_OR_ZERO (0) => 0x00000000
+ * - BITS_ONES_OR_ZERO (1) => 0x00000001
+ * - BITS_ONES_OR_ZERO (15) => 0x00007fff
+ * - BITS_ONES_OR_ZERO (32) => 0xffffffff
+ */
+#define BITS_ONES_OR_ZERO(b) ({ typeof (b) _b = (b);\
+ _b ? ((1u << (_b - 1) << 1) - 1) : 0; })
+
/** Return a bit mask composed of a number of LSB ones, corresponding to the
* given bit field.
* \param f bit field define