[v4,3/5] batman-adv: use BIT_ULL for NL80211_STA_INFO_* attribute types

Message ID 1529491616-23222-1-git-send-email-omer.efrat@tandemg.com (mailing list archive)
State Rejected, archived
Delegated to: Simon Wunderlich
Headers
Series None |

Commit Message

Omer Efrat June 20, 2018, 10:46 a.m. UTC
  The BIT macro uses unsigned long which some architectures handle as 32 bit
and therefore might cause macro's shift to overflow when used on a value
equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).

Since 'filled' member in station_info changed to u64, BIT_ULL macro
should be used with all NL80211_STA_INFO_* attribute types instead of BIT
to prevent future possible bugs when one will use BIT macro for higher
attributes by mistake.

This commit cleans up all usages of BIT macro with the above field
in batman-adv by changing it to BIT_ULL instead.

Signed-off-by: Omer Efrat <omer.efrat@tandemg.com>
---
 net/batman-adv/bat_v_elp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Sven Eckelmann June 20, 2018, 11:34 a.m. UTC | #1
On Mittwoch, 20. Juni 2018 13:46:56 CEST Omer Efrat wrote:
> -               if (!(sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT)))
> +               if (!(sinfo.filled &
> +                         BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT)))
>                         goto default_throughput;

Please fix the alignment:

* Found wrong alignment at net/batman-adv/bat_v_elp.c:118, was 27 but expected 23

Kind regards,
	Sven
  
Sven Eckelmann June 25, 2018, 3:15 p.m. UTC | #2
On Montag, 25. Juni 2018 14:31:19 CEST Omer Efrat wrote:
> Sven Eckelmann wrote:
> >Please fix the alignment:
> >
> >* Found wrong alignment at net/batman-adv/bat_v_elp.c:118, was 27 but expected 23
> 
> checkpatch script doesn't catch this error.
> how do I see this?

I saw it with my eyes. But the script bracket_align.py [1] prints the actual 
message.

Kind regards,
	Sven

[1] https://git.open-mesh.org/build_test.git/blob/HEAD:/testhelpers/bracket_align.py
  

Patch

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 71c20c1..2f0de55 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -114,7 +114,8 @@  static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
 		}
 		if (ret)
 			goto default_throughput;
-		if (!(sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT)))
+		if (!(sinfo.filled &
+			  BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT)))
 			goto default_throughput;
 
 		return sinfo.expected_throughput / 100;