diff mbox series

ap: Fix build warning about type mismatch

Message ID 20231218155256.605832-1-Chaitanya.Tata@nordicsemi.no
State New
Headers show
Series ap: Fix build warning about type mismatch | expand

Commit Message

Krishna Chaitanya Dec. 18, 2023, 3:52 p.m. UTC
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@nordicsemi.no>
---
 src/ap/ieee802_1x.c | 2 +-
 src/utils/common.h  | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Andrei Otcheretianski Dec. 26, 2023, 10:08 a.m. UTC | #1
> --- 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

How is this different from BIT definition just a couple of lines above?
You probably have some other incorrect BIT macro somewhere so you don't take the #ifndef BIT.

> +
>  /*
>   * Definitions for sparse validation
>   * (http://kernel.org/pub/linux/kernel/people/josh/sparse/)
> --
> 2.25.1
> 
> 
> _______________________________________________
> Hostap mailing list
> Hostap@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/hostap
diff mbox series

Patch

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/)