From 9e5ffffb6853aafb6441193e27f60576a67a2e32 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 22 Jun 2018 20:39:32 +0100 Subject: staging: wlan-ng: replace WLAN_CTL_FRAMELEN with inline function in p80211hdr.h checkpatch reports a "CHECK" diagnostic for WLAN_CTL_FRAMELEN as the macro reuses its argument, leading to possible side-effects. Avoid this by replacing the macro with an equivalent function, named wlan_ctl_framelen (as recommended in the coding style). All references to the macro also updated accordingly. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211hdr.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'drivers/staging/wlan-ng/p80211hdr.h') diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h index 26b178721414..6564810fd026 100644 --- a/drivers/staging/wlan-ng/p80211hdr.h +++ b/drivers/staging/wlan-ng/p80211hdr.h @@ -174,15 +174,25 @@ union p80211_hdr { /* Frame and header length macros */ -#define WLAN_CTL_FRAMELEN(fstype) (\ - (fstype) == WLAN_FSTYPE_BLOCKACKREQ ? 24 : \ - (fstype) == WLAN_FSTYPE_BLOCKACK ? 152 : \ - (fstype) == WLAN_FSTYPE_PSPOLL ? 20 : \ - (fstype) == WLAN_FSTYPE_RTS ? 20 : \ - (fstype) == WLAN_FSTYPE_CTS ? 14 : \ - (fstype) == WLAN_FSTYPE_ACK ? 14 : \ - (fstype) == WLAN_FSTYPE_CFEND ? 20 : \ - (fstype) == WLAN_FSTYPE_CFENDCFACK ? 20 : 4) +static inline u16 wlan_ctl_framelen(u16 fstype) +{ + switch (fstype) { + case WLAN_FSTYPE_BLOCKACKREQ: + return 24; + case WLAN_FSTYPE_BLOCKACK: + return 152; + case WLAN_FSTYPE_PSPOLL: + case WLAN_FSTYPE_RTS: + case WLAN_FSTYPE_CFEND: + case WLAN_FSTYPE_CFENDCFACK: + return 20; + case WLAN_FSTYPE_CTS: + case WLAN_FSTYPE_ACK: + return 14; + default: + return 4; + } +} #define WLAN_FCS_LEN 4 @@ -201,7 +211,7 @@ static inline u16 p80211_headerlen(u16 fctl) hdrlen += ETH_ALEN; break; case WLAN_FTYPE_CTL: - hdrlen = WLAN_CTL_FRAMELEN(WLAN_GET_FC_FSTYPE(fctl)) - + hdrlen = wlan_ctl_framelen(WLAN_GET_FC_FSTYPE(fctl)) - WLAN_FCS_LEN; break; default: -- cgit v1.2.3