From: Joe Perches <joe@perches.com>
To: B K Karthik <bkkarthik@pesu.pes.edu>,
Larry Finger <Larry.Finger@lwfinger.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michael Straube <straube.linux@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] staging: rtl8188eu: include: placed constant on the right side of the test in comparisons
Date: Sat, 18 Jul 2020 06:17:12 -0700 [thread overview]
Message-ID: <560eeb7388164e58ac0e47277fe2aec798c45a5c.camel@perches.com> (raw)
In-Reply-To: <20200718091857.quzs5sqvkjzngd6k@pesu-pes-edu>
On Sat, 2020-07-18 at 05:18 -0400, B K Karthik wrote:
> placed constant on the right side of the test
> to fix warnings issued by checkpatch
[]
> diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h
[]
> @@ -326,7 +326,7 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
>
> static inline int IsFrameTypeCtrl(unsigned char *pframe)
> {
> - if (WIFI_CTRL_TYPE == GetFrameType(pframe))
> + if (GetFrameType(pframe) == WIFI_CTRL_TYPE)
> return true;
> else
> return false;
Always try to improve code instead of merely shutting
up checkpatch warnings.
This function should likely be written:
static inline bool IsFrameTypeCtrl(unsigned char *pframe)
{
return GetFrameType(pframe) == WIFI_CTRL_TYPE;
}
and given it's used only once, it might be expanded
in that place and removed altogether.
Something like:
(and the memcmp below could be ether_addr_equal instead
but I'm too lazy to find out if the addresses are both
guaranteed to be __aligned(2) which is likely)
---
drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 8 +++++---
drivers/staging/rtl8188eu/include/wifi.h | 7 -------
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c
index 7d0135fde795..a2994f9ecbde 100644
--- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c
+++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c
@@ -144,10 +144,12 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
wlanhdr = precvframe->pkt->data;
- pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) &&
- !pattrib->icv_err && !pattrib->crc_err &&
+ pkt_info.bPacketMatchBSSID =
+ GetFrameType(wlanhdr) != WIFI_CTRL_TYPE &&
+ !pattrib->icv_err &&
+ !pattrib->crc_err &&
!memcmp(get_hdr_bssid(wlanhdr),
- get_bssid(&padapter->mlmepriv), ETH_ALEN));
+ get_bssid(&padapter->mlmepriv), ETH_ALEN);
pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID &&
(!memcmp(get_da(wlanhdr),
diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h
index 791f287a546d..3998d5633860 100644
--- a/drivers/staging/rtl8188eu/include/wifi.h
+++ b/drivers/staging/rtl8188eu/include/wifi.h
@@ -324,13 +324,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
return sa;
}
-static inline int IsFrameTypeCtrl(unsigned char *pframe)
-{
- if (WIFI_CTRL_TYPE == GetFrameType(pframe))
- return true;
- else
- return false;
-}
/*-----------------------------------------------------------------------------
Below is for the security related definition
------------------------------------------------------------------------------*/
next prev parent reply other threads:[~2020-07-18 13:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-18 9:18 B K Karthik
2020-07-18 13:17 ` Joe Perches [this message]
2020-07-18 13:34 ` B K Karthik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=560eeb7388164e58ac0e47277fe2aec798c45a5c.camel@perches.com \
--to=joe@perches.com \
--cc=Larry.Finger@lwfinger.net \
--cc=bkkarthik@pesu.pes.edu \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=straube.linux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®