From a3824b4aac0e894699ca2643af5887239a6c489a Mon Sep 17 00:00:00 2001 From: Christian Eggers Date: Tue, 8 Jul 2025 14:59:47 +0200 Subject: [PATCH] mesh: use '0x1' rathen than 'true' for bit operations Although 'true' expands to 1, it feels more natural using '0x1' (or '1') when performing masking or bit shifting operations. --- mesh/crypto.c | 6 +++--- mesh/net.c | 4 ++-- mesh/net.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mesh/crypto.c b/mesh/crypto.c index a9d670485..31001d283 100644 --- a/mesh/crypto.c +++ b/mesh/crypto.c @@ -640,7 +640,7 @@ bool mesh_crypto_packet_parse(const uint8_t *packet, uint8_t packet_len, hdr = l_get_be32(packet + 9); - is_segmented = !!((hdr >> SEG_HDR_SHIFT) & true); + is_segmented = !!((hdr >> SEG_HDR_SHIFT) & 0x1); if (segmented) *segmented = is_segmented; @@ -655,7 +655,7 @@ bool mesh_crypto_packet_parse(const uint8_t *packet, uint8_t packet_len, if (this_dst && this_opcode == NET_OP_SEG_ACKNOWLEDGE) { if (relay) - *relay = !!((hdr >> RELAY_HDR_SHIFT) & true); + *relay = !!((hdr >> RELAY_HDR_SHIFT) & 0x1); if (seqZero) *seqZero = (hdr >> SEQ_ZERO_HDR_SHIFT) & @@ -682,7 +682,7 @@ bool mesh_crypto_packet_parse(const uint8_t *packet, uint8_t packet_len, if (is_segmented) { if (szmic) - *szmic = !!((hdr >> SZMIC_HDR_SHIFT) & true); + *szmic = !!((hdr >> SZMIC_HDR_SHIFT) & 0x1); if (seqZero) *seqZero = (hdr >> SEQ_ZERO_HDR_SHIFT) & diff --git a/mesh/net.c b/mesh/net.c index d11de58dd..d711f80c8 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -3195,9 +3195,9 @@ void mesh_net_send_seg(struct mesh_net *net, uint32_t net_key_id, { uint8_t packet[30]; uint8_t packet_len; - bool segmented = !!((hdr >> SEG_HDR_SHIFT) & true); + bool segmented = !!((hdr >> SEG_HDR_SHIFT) & 0x1); uint8_t key_aid = (hdr >> KEY_HDR_SHIFT) & KEY_ID_MASK; - bool szmic = !!((hdr >> SZMIC_HDR_SHIFT) & true); + bool szmic = !!((hdr >> SZMIC_HDR_SHIFT) & 0x1); uint16_t seqZero = (hdr >> SEQ_ZERO_HDR_SHIFT) & SEQ_ZERO_MASK; uint8_t segO = (hdr >> SEGO_HDR_SHIFT) & SEG_MASK; uint8_t segN = (hdr >> SEGN_HDR_SHIFT) & SEG_MASK; diff --git a/mesh/net.h b/mesh/net.h index 8a3b4038b..bdb797e12 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -65,9 +65,9 @@ struct mesh_node; /* Mask of Hdr bits which must be constant over entire incoming SAR message */ /* (SEG || AKF || AID || SZMIC || SeqZero || SegN) */ -#define HDR_KEY_MASK ((true << SEG_HDR_SHIFT) | \ +#define HDR_KEY_MASK ((0x1 << SEG_HDR_SHIFT) | \ (KEY_ID_MASK << KEY_HDR_SHIFT) | \ - (true << SZMIC_HDR_SHIFT) | \ + (0x1 << SZMIC_HDR_SHIFT) | \ (SEQ_ZERO_MASK << SEQ_ZERO_HDR_SHIFT) | \ (SEG_MASK << SEGN_HDR_SHIFT)) -- 2.47.3