From 4e5a3a80a8425d144ba70b23b02a1bed0d89c352 Mon Sep 17 00:00:00 2001 From: Christian Eggers Date: Tue, 8 Jul 2025 14:59:46 +0200 Subject: [PATCH] mesh: remove unneeded casts to bool The result of these expression is already of type 'bool'. --- mesh/crypto.c | 2 +- mesh/friend.c | 2 +- mesh/mesh-io-mgmt.c | 2 +- mesh/mesh-io-unit.c | 2 +- mesh/net.c | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mesh/crypto.c b/mesh/crypto.c index 136e69535..a9d670485 100644 --- a/mesh/crypto.c +++ b/mesh/crypto.c @@ -67,7 +67,7 @@ static bool aes_cmac_one(const uint8_t key[16], const void *msg, if (result) { ssize_t len = l_checksum_get_digest(checksum, res, 16); - result = !!(len == 16); + result = (len == 16); } l_checksum_free(checksum); diff --git a/mesh/friend.c b/mesh/friend.c index 6aacf6338..1c60705e0 100644 --- a/mesh/friend.c +++ b/mesh/friend.c @@ -521,7 +521,7 @@ void friend_poll(struct mesh_net *net, uint16_t src, bool seq, frnd->u.active.seq = seq; frnd->u.active.last = !seq; - md = !!(l_queue_length(frnd->pkt_cache) > 1); + md = (l_queue_length(frnd->pkt_cache) > 1); if (pkt->ctl) { /* Make sure we don't change the bit-sense of MD, diff --git a/mesh/mesh-io-mgmt.c b/mesh/mesh-io-mgmt.c index 0d3285979..4ca7ff93c 100644 --- a/mesh/mesh-io-mgmt.c +++ b/mesh/mesh-io-mgmt.c @@ -581,7 +581,7 @@ static void tx_to(struct l_timeout *timeout, void *user_data) count = 1; } - tx->delete = !!(count == 1); + tx->delete = (count == 1); send_pkt(pvt, tx, ms); diff --git a/mesh/mesh-io-unit.c b/mesh/mesh-io-unit.c index 4fd72bf84..936f5a951 100644 --- a/mesh/mesh-io-unit.c +++ b/mesh/mesh-io-unit.c @@ -341,7 +341,7 @@ static void tx_to(struct l_timeout *timeout, void *user_data) count = 1; } - tx->delete = !!(count == 1); + tx->delete = (count == 1); send_pkt(pvt, tx, ms); diff --git a/mesh/net.c b/mesh/net.c index ccfaaf282..d11de58dd 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -617,7 +617,7 @@ static void refresh_beacon(void *a, void *b) struct mesh_net *net = b; net_key_beacon_refresh(subnet->net_key_tx, net->iv_index, - !!(subnet->kr_phase == KEY_REFRESH_PHASE_TWO), net->iv_update, + subnet->kr_phase == KEY_REFRESH_PHASE_TWO, net->iv_update, false); } @@ -2820,7 +2820,7 @@ static void process_beacon(void *net_ptr, void *user_data) /* Get IVU and KR boolean bits from beacon */ ivu = beacon_data->ivu; kr = beacon_data->kr; - local_kr = !!(subnet->kr_phase == KEY_REFRESH_PHASE_TWO); + local_kr = (subnet->kr_phase == KEY_REFRESH_PHASE_TWO); /* We have officially *seen* this beacon now */ beacon_data->processed = true; @@ -2842,7 +2842,7 @@ static void process_beacon(void *net_ptr, void *user_data) if (updated) net_key_beacon_refresh(beacon_data->net_key_id, net->iv_index, - !!(subnet->kr_phase == KEY_REFRESH_PHASE_TWO), + subnet->kr_phase == KEY_REFRESH_PHASE_TWO, net->iv_update, false); } } @@ -2985,7 +2985,7 @@ bool mesh_net_set_key(struct mesh_net *net, uint16_t idx, const uint8_t *key, subnet->kr_phase = phase; net_key_beacon_refresh(subnet->net_key_tx, net->iv_index, - !!(subnet->kr_phase == KEY_REFRESH_PHASE_TWO), net->iv_update, + subnet->kr_phase == KEY_REFRESH_PHASE_TWO, net->iv_update, false); -- 2.47.3