public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Tobin C. Harding" <me@tobin.cc>
To: Quytelda Kahja <quytelda@tamalin.org>
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	driverdev-devel@linuxdriverproject.org,
	linux-kernel@vger.kernel.org, wsa@the-dreams.de
Subject: Re: [PATCH 1/5] staging: ks7010: Use constants from ieee80211_eid instead of literal ints.
Date: Thu, 1 Mar 2018 17:33:40 +1100	[thread overview]
Message-ID: <20180301063340.GB4059@eros> (raw)
In-Reply-To: <20180301051911.1314-1-quytelda@tamalin.org>

On Wed, Feb 28, 2018 at 09:19:07PM -0800, Quytelda Kahja wrote:
> The case statement in get_ap_information() should not use literal integers
> to parse information element IDs when these values are provided by name
> in 'enum ieee80211_eid' in the header 'linux/ieee80211.h'.

Nice.  Magic number removal, I like it.

> Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
> ---
>  drivers/staging/ks7010/ks_hostif.c | 31 +++++++++++++++----------------
>  drivers/staging/ks7010/ks_hostif.h |  1 +
>  2 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
> index 74a08417bd0b..67cf32433023 100644
> --- a/drivers/staging/ks7010/ks_hostif.c
> +++ b/drivers/staging/ks7010/ks_hostif.c
> @@ -251,9 +251,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
>  	offset = 0;
>  
>  	while (bsize > offset) {
> -		/* DPRINTK(4, "Element ID=%d\n",*bp); */

nit: Probably shouldn't remove debugging output in the same patch as
doing magic number removal.  (super nit-picky though.)

> -		switch (*bp) {
> -		case 0:	/* ssid */
> +		switch (*bp) { /* Information Element ID */
> +		case WLAN_EID_SSID:
>  			if (*(bp + 1) <= SSID_MAX_SIZE) {
>  				ap->ssid.size = *(bp + 1);
>  			} else {
> @@ -263,8 +262,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
>  			}
>  			memcpy(ap->ssid.body, bp + 2, ap->ssid.size);
>  			break;
> -		case 1:	/* rate */
> -		case 50:	/* ext rate */
> +		case WLAN_EID_SUPP_RATES:
> +		case WLAN_EID_EXT_SUPP_RATES:
>  			if ((*(bp + 1) + ap->rate_set.size) <=
>  			    RATE_SET_MAX_SIZE) {
>  				memcpy(&ap->rate_set.body[ap->rate_set.size],
> @@ -280,9 +279,9 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
>  				    (RATE_SET_MAX_SIZE - ap->rate_set.size);
>  			}
>  			break;
> -		case 3:	/* DS parameter */
> +		case WLAN_EID_DS_PARAMS:
>  			break;
> -		case 48:	/* RSN(WPA2) */
> +		case WLAN_EID_RSN:
>  			ap->rsn_ie.id = *bp;
>  			if (*(bp + 1) <= RSN_IE_BODY_MAX) {
>  				ap->rsn_ie.size = *(bp + 1);
> @@ -293,8 +292,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
>  			}
>  			memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size);
>  			break;
> -		case 221:	/* WPA */
> -			if (memcmp(bp + 2, "\x00\x50\xf2\x01", 4) == 0) {	/* WPA OUI check */
> +		case WLAN_EID_VENDOR_SPECIFIC: /* WPA */
> +			if (memcmp(bp + 2, "\x00\x50\xf2\x01", 4) == 0) { /* WPA OUI check */

Shouldn't have this line (unnecessary white space change)

>  				ap->wpa_ie.id = *bp;
>  				if (*(bp + 1) <= RSN_IE_BODY_MAX) {
>  					ap->wpa_ie.size = *(bp + 1);
> @@ -309,18 +308,18 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
>  			}
>  			break;
>  
> -		case 2:	/* FH parameter */
> -		case 4:	/* CF parameter */
> -		case 5:	/* TIM */
> -		case 6:	/* IBSS parameter */
> -		case 7:	/* Country */
> -		case 42:	/* ERP information */
> -		case 47:	/* Reserve ID 47 Broadcom AP */
> +		case WLAN_EID_FH_PARAMS:
> +		case WLAN_EID_CF_PARAMS:
> +		case WLAN_EID_TIM:
> +		case WLAN_EID_IBSS_PARAMS:
> +		case WLAN_EID_COUNTRY:
> +		case WLAN_EID_ERP_INFO:
>  			break;
>  		default:
>  			DPRINTK(4, "unknown Element ID=%d\n", *bp);
>  			break;
>  		}
> +

FTR try not to include unrelated whitespace changes.  I see you changed
the case statement but the whitespace is after it and not really
related.  Again quite nit-picky but I'm guessing you are in staging to
learn so might as well learn it now than when you are patching the core
kernel :)


Good work,
Tobin.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  parent reply	other threads:[~2018-03-01  6:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01  5:19 [PATCH 1/5] staging: ks7010: Use constants from ieee80211_eid instead of literal ints Quytelda Kahja
2018-03-01  5:19 ` [PATCH 2/5] staging: ks7010: Replace SSID_MAX_SIZE with IEEE80211_MAX_SSID_LEN Quytelda Kahja
2018-03-01  5:19 ` [PATCH 3/5] staging: ks7010: Factor out repeated code into function 'ks_wlan_cap()' Quytelda Kahja
2018-03-01  6:37   ` Tobin C. Harding
2018-03-01 11:15     ` Dan Carpenter
2018-03-01 20:54       ` Tobin C. Harding
2018-03-02  1:28         ` Quytelda Kahja
2018-03-02  2:21           ` Tobin C. Harding
2018-03-02  9:07           ` Dan Carpenter
2018-03-02  9:05         ` Dan Carpenter
2018-03-04 22:57           ` Tobin C. Harding
2018-03-01  5:19 ` [PATCH 4/5] staging: ks7010: Replace local capability constants with kernel constants Quytelda Kahja
2018-03-01  5:19 ` [PATCH 5/5] staging: ks7010: Replace local frame type " Quytelda Kahja
2018-03-01  6:33 ` Tobin C. Harding [this message]
2018-03-01  6:34 ` [PATCH 1/5] staging: ks7010: Use constants from ieee80211_eid instead of literal ints Tobin C. Harding

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=20180301063340.GB4059@eros \
    --to=me@tobin.cc \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quytelda@tamalin.org \
    --cc=wsa@the-dreams.de \
    /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