[PATCH] ap: Fix build warning about type mismatch
Chaitanya Tata
chaitanya.mgit at gmail.com
Mon Dec 18 07:52:56 PST 2023
The negation produces "long unsigned int" and as we use %d this causes
a build warning with `-Wformat=`, introduce a bit macro for u8 to fix
this.
Note, the warning is only seen if the size of integer is different from
unsigned long, so, on typical desktop it's not seen.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata at nordicsemi.no>
---
src/ap/ieee802_1x.c | 2 +-
src/utils/common.h | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index 052231e34..4aaf2c95b 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -2728,7 +2728,7 @@ int ieee802_1x_eapol_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
HOSTAPD_LEVEL_DEBUG,
"did not Ack EAPOL-Key frame (%scast index=%d)",
key->key_index & BIT(7) ? "uni" : "broad",
- key->key_index & ~BIT(7));
+ key->key_index & ~BIT_U8(7));
/* TODO: re-send EAPOL-Key couple of times (with short delay
* between them?). If all attempt fail, report error and
* deauthenticate STA so that it will get new keys when
diff --git a/src/utils/common.h b/src/utils/common.h
index bede21e57..b4e785e1e 100644
--- a/src/utils/common.h
+++ b/src/utils/common.h
@@ -441,6 +441,10 @@ void perror(const char *s);
#define BIT(x) (1U << (x))
#endif
+#ifndef BIT_U8
+#define BIT_U8(n) (1U << (n))
+#endif
+
/*
* Definitions for sparse validation
* (http://kernel.org/pub/linux/kernel/people/josh/sparse/)
--
2.25.1
More information about the Hostap
mailing list