From: Ajay Singh <ajay.kathat@microchip.com>
To: Claudiu Beznea <Claudiu.Beznea@microchip.com>
Cc: <linux-wireless@vger.kernel.org>, <devel@driverdev.osuosl.org>,
<gregkh@linuxfoundation.org>, <ganesh.krishna@microchip.com>,
<venkateswara.kaja@microchip.com>, <aditya.shankar@microchip.com>,
<adham.abozaeid@Microchip.com>
Subject: Re: [PATCH 07/30] staging: wilc1000: fix line over 80 characters in host_int_parse_join_bss_param()
Date: Thu, 10 May 2018 00:11:17 +0530 [thread overview]
Message-ID: <20180510001117.26a29f19@ajaysk-VirtualBox> (raw)
In-Reply-To: <41b47474-9dad-05c8-aa1b-0da661de3caf@microchip.com>
On Wed, 9 May 2018 16:43:59 +0300
Claudiu Beznea <Claudiu.Beznea@microchip.com> wrote:
> On 07.05.2018 11:43, Ajay Singh wrote:
> > Split host_int_parse_join_bss_param() to avoid the line over 80
> > character issue reported by checkpatch.pl script.
> >
> > Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
> > ---
> > drivers/staging/wilc1000/host_interface.c | 247
> > ++++++++++++++++-------------- 1 file changed, 131 insertions(+),
> > 116 deletions(-)
> >
> > diff --git a/drivers/staging/wilc1000/host_interface.c
> > b/drivers/staging/wilc1000/host_interface.c index 0d84af9..c9c5d352
> > 100644 --- a/drivers/staging/wilc1000/host_interface.c
> > +++ b/drivers/staging/wilc1000/host_interface.c
> > @@ -3856,150 +3856,165 @@ int wilc_setup_multicast_filter(struct
> > wilc_vif *vif, bool enabled, return result;
> > }
> >
> > -static void *host_int_parse_join_bss_param(struct network_info
> > *info) +static void host_int_fill_join_bss_param(struct
> > join_bss_param *param, u8 *ies,
> > + u16 *out_index, u8
> > *pcipher_tc,
> > + u8 *auth_total_cnt, u32
> > tsf_lo) {
> > - struct join_bss_param *param = NULL;
> > - u8 *ies;
> > - u16 ies_len;
> > - u16 index = 0;
> > u8 rates_no = 0;
> > u8 ext_rates_no;
> > u16 offset;
> > u8 pcipher_cnt;
> > u8 auth_cnt;
> > - u8 pcipher_total_cnt = 0;
> > - u8 auth_total_cnt = 0;
> > u8 i, j;
> > + u16 index = *out_index;
>
> Why not having a single index, the one passed as argument?
>
If we use 'index' argument then we have to change all the lines below
with '*index' and it would make code look more complicated. So to
reduce those changes below I have the above logic.
> >
> > - ies = info->ies;
> > - ies_len = info->ies_len;
> > + if (ies[index] == SUPP_RATES_IE) {
> > + rates_no = ies[index + 1];
> > + param->supp_rates[0] = rates_no;
> > + index += 2;
> >
> > - param = kzalloc(sizeof(*param), GFP_KERNEL);
> > - if (!param)
> > - return NULL;
> > + for (i = 0; i < rates_no; i++)
> > + param->supp_rates[i + 1] = ies[index + i];
> >
> > - param->dtim_period = info->dtim_period;
> > - param->beacon_period = info->beacon_period;
> > - param->cap_info = info->cap_info;
> > - memcpy(param->bssid, info->bssid, 6);
> > - memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1);
> > - param->ssid_len = info->ssid_len;
> > - memset(param->rsn_pcip_policy, 0xFF, 3);
> > - memset(param->rsn_auth_policy, 0xFF, 3);
> > + index += rates_no;
> > + } else if (ies[index] == EXT_SUPP_RATES_IE) {
> > + ext_rates_no = ies[index + 1];
> > + if (ext_rates_no > (MAX_RATES_SUPPORTED -
> > rates_no))
> > + param->supp_rates[0] = MAX_RATES_SUPPORTED;
> > + else
> > + param->supp_rates[0] += ext_rates_no;
> > + index += 2;
> > + for (i = 0; i < (param->supp_rates[0] - rates_no);
> > i++)
> > + param->supp_rates[rates_no + i + 1] =
> > ies[index + i]; +
> > + index += ext_rates_no;
> > + } else if (ies[index] == HT_CAPABILITY_IE) {
> > + param->ht_capable = true;
> > + index += ies[index + 1] + 2;
> > + } else if ((ies[index] == WMM_IE) &&
> > + (ies[index + 2] == 0x00) && (ies[index + 3] ==
> > 0x50) &&
> > + (ies[index + 4] == 0xF2) && (ies[index + 5] ==
> > 0x02) &&
> > + ((ies[index + 6] == 0x00) || (ies[index + 6] ==
> > 0x01)) &&
> > + (ies[index + 7] == 0x01)) {
> > + param->wmm_cap = true;
> > +
> > + if (ies[index + 8] & BIT(7))
> > + param->uapsd_cap = true;
> > + index += ies[index + 1] + 2;
> > + } else if ((ies[index] == P2P_IE) &&
> > + (ies[index + 2] == 0x50) && (ies[index + 3] ==
> > 0x6f) &&
> > + (ies[index + 4] == 0x9a) &&
> > + (ies[index + 5] == 0x09) && (ies[index + 6] ==
> > 0x0c)) {
> > + u16 p2p_cnt;
> > +
> > + param->tsf = tsf_lo;
> > + param->noa_enabled = 1;
> > + param->idx = ies[index + 9];
> > +
> > + if (ies[index + 10] & BIT(7)) {
> > + param->opp_enabled = 1;
> > + param->ct_window = ies[index + 10];
> > + } else {
> > + param->opp_enabled = 0;
> > + }
> >
> > - while (index < ies_len) {
> > - if (ies[index] == SUPP_RATES_IE) {
> > - rates_no = ies[index + 1];
> > - param->supp_rates[0] = rates_no;
> > - index += 2;
> > + param->cnt = ies[index + 11];
> > + p2p_cnt = index + 12;
> >
> > - for (i = 0; i < rates_no; i++)
> > - param->supp_rates[i + 1] =
> > ies[index + i];
> > + memcpy(param->duration, ies + p2p_cnt, 4);
> > + p2p_cnt += 4;
> >
> > - index += rates_no;
> > - } else if (ies[index] == EXT_SUPP_RATES_IE) {
> > - ext_rates_no = ies[index + 1];
> > - if (ext_rates_no > (MAX_RATES_SUPPORTED -
> > rates_no))
> > - param->supp_rates[0] =
> > MAX_RATES_SUPPORTED;
> > - else
> > - param->supp_rates[0] +=
> > ext_rates_no;
> > - index += 2;
> > - for (i = 0; i < (param->supp_rates[0] -
> > rates_no); i++)
> > - param->supp_rates[rates_no + i +
> > 1] = ies[index + i]; -
> > - index += ext_rates_no;
> > - } else if (ies[index] == HT_CAPABILITY_IE) {
> > - param->ht_capable = true;
> > - index += ies[index + 1] + 2;
> > - } else if ((ies[index] == WMM_IE) &&
> > - (ies[index + 2] == 0x00) && (ies[index
> > + 3] == 0x50) &&
> > - (ies[index + 4] == 0xF2) &&
> > - (ies[index + 5] == 0x02) &&
> > - ((ies[index + 6] == 0x00) || (ies[index
> > + 6] == 0x01)) &&
> > - (ies[index + 7] == 0x01)) {
> > - param->wmm_cap = true;
> > -
> > - if (ies[index + 8] & BIT(7))
> > - param->uapsd_cap = true;
> > - index += ies[index + 1] + 2;
> > - } else if ((ies[index] == P2P_IE) &&
> > - (ies[index + 2] == 0x50) && (ies[index +
> > 3] == 0x6f) &&
> > - (ies[index + 4] == 0x9a) &&
> > - (ies[index + 5] == 0x09) && (ies[index +
> > 6] == 0x0c)) {
> > - u16 p2p_cnt;
> > -
> > - param->tsf = info->tsf_lo;
> > - param->noa_enabled = 1;
> > - param->idx = ies[index + 9];
> > -
> > - if (ies[index + 10] & BIT(7)) {
> > - param->opp_enabled = 1;
> > - param->ct_window = ies[index + 10];
> > - } else {
> > - param->opp_enabled = 0;
> > - }
> > + memcpy(param->interval, ies + p2p_cnt, 4);
> > + p2p_cnt += 4;
> >
> > - param->cnt = ies[index + 11];
> > - p2p_cnt = index + 12;
> > + memcpy(param->start_time, ies + p2p_cnt, 4);
> >
> > - memcpy(param->duration, ies + p2p_cnt, 4);
> > - p2p_cnt += 4;
> > + index += ies[index + 1] + 2;
> > + } else if ((ies[index] == RSN_IE) ||
> > + ((ies[index] == WPA_IE) && (ies[index + 2] ==
> > 0x00) &&
> > + (ies[index + 3] == 0x50) && (ies[index + 4] ==
> > 0xF2) &&
> > + (ies[index + 5] == 0x01))) {
> > + u16 rsn_idx = index;
> >
> > - memcpy(param->interval, ies + p2p_cnt, 4);
> > - p2p_cnt += 4;
> > + if (ies[rsn_idx] == RSN_IE) {
> > + param->mode_802_11i = 2;
> > + } else {
> > + if (param->mode_802_11i == 0)
> > + param->mode_802_11i = 1;
> > + rsn_idx += 4;
> > + }
> >
> > - memcpy(param->start_time, ies + p2p_cnt,
> > 4);
> > + rsn_idx += 7;
> > + param->rsn_grp_policy = ies[rsn_idx];
> > + rsn_idx++;
> > + offset = ies[rsn_idx] * 4;
> > + pcipher_cnt = (ies[rsn_idx] > 3) ? 3 :
> > ies[rsn_idx];
> > + rsn_idx += 2;
> >
> > - index += ies[index + 1] + 2;
> > - } else if ((ies[index] == RSN_IE) ||
> > - ((ies[index] == WPA_IE) && (ies[index +
> > 2] == 0x00) &&
> > - (ies[index + 3] == 0x50) && (ies[index +
> > 4] == 0xF2) &&
> > - (ies[index + 5] == 0x01))) {
> > - u16 rsn_idx = index;
> > + i = *pcipher_tc;
> > + j = 0;
> > + for (; i < (pcipher_cnt + *pcipher_tc) && i < 3;
> > i++, j++) {
> > + u8 *policy = ¶m->rsn_pcip_policy[i];
> >
> > - if (ies[rsn_idx] == RSN_IE) {
> > - param->mode_802_11i = 2;
> > - } else {
> > - if (param->mode_802_11i == 0)
> > - param->mode_802_11i = 1;
> > - rsn_idx += 4;
> > - }
> > + *policy = ies[rsn_idx + ((j + 1) * 4) - 1];
> > + }
> >
> > - rsn_idx += 7;
> > - param->rsn_grp_policy = ies[rsn_idx];
> > - rsn_idx++;
> > - offset = ies[rsn_idx] * 4;
> > - pcipher_cnt = (ies[rsn_idx] > 3) ? 3 :
> > ies[rsn_idx];
> > - rsn_idx += 2;
> > + *pcipher_tc += pcipher_cnt;
> > + rsn_idx += offset;
> >
> > - for (i = pcipher_total_cnt, j = 0; i <
> > pcipher_cnt + pcipher_total_cnt && i < 3; i++, j++)
> > - param->rsn_pcip_policy[i] =
> > ies[rsn_idx + ((j + 1) * 4) - 1];
> > + offset = ies[rsn_idx] * 4;
> >
> > - pcipher_total_cnt += pcipher_cnt;
> > - rsn_idx += offset;
> > + auth_cnt = (ies[rsn_idx] > 3) ? 3 : ies[rsn_idx];
> > + rsn_idx += 2;
> > + i = *auth_total_cnt;
> > + j = 0;
>
> I prefer keeping these inside for (). I think some of the "line over
> 80" should be fixed by refactoring code not introducing new variables
> and so on.
Do you think for the below line the 'line over 80 chars' can be solved
by refactoring alone and without using temp/intermediate variables
or short names of variables.
The original 'for' loop line itself was about 65+ characters long.
>
> > + for (; i < (*auth_total_cnt + auth_cnt); i++, j++)
> > {
> > + u8 *policy = ¶m->rsn_auth_policy[i];
> >
> > - offset = ies[rsn_idx] * 4;
> > + *policy = ies[rsn_idx + ((j + 1) * 4) - 1];
> > + }
> > +
> > + auth_total_cnt += auth_cnt;
> > + rsn_idx += offset;
> >
> > - auth_cnt = (ies[rsn_idx] > 3) ? 3 :
> > ies[rsn_idx];
> > + if (ies[index] == RSN_IE) {
> > + param->rsn_cap[0] = ies[rsn_idx];
> > + param->rsn_cap[1] = ies[rsn_idx + 1];
> > rsn_idx += 2;
> > + }
> > + param->rsn_found = true;
> > + index += ies[index + 1] + 2;
> > + } else {
> > + index += ies[index + 1] + 2;
> > + }
> >
> > - for (i = auth_total_cnt, j = 0; i <
> > auth_total_cnt + auth_cnt; i++, j++)
> > - param->rsn_auth_policy[i] =
> > ies[rsn_idx + ((j + 1) * 4) - 1];
> > + *out_index = index;
> > +}
> >
> > - auth_total_cnt += auth_cnt;
> > - rsn_idx += offset;
> > +static void *host_int_parse_join_bss_param(struct network_info
> > *info) +{
> > + struct join_bss_param *param = NULL;
> > + u16 index = 0;
> > + u8 pcipher_total_cnt = 0;
> > + u8 auth_total_cnt = 0;
> >
> > - if (ies[index] == RSN_IE) {
> > - param->rsn_cap[0] = ies[rsn_idx];
> > - param->rsn_cap[1] = ies[rsn_idx +
> > 1];
> > - rsn_idx += 2;
> > - }
> > - param->rsn_found = true;
> > - index += ies[index + 1] + 2;
> > - } else {
> > - index += ies[index + 1] + 2;
> > - }
> > - }
> > + param = kzalloc(sizeof(*param), GFP_KERNEL);
> > + if (!param)
> > + return NULL;
> > +
> > + param->dtim_period = info->dtim_period;
> > + param->beacon_period = info->beacon_period;
> > + param->cap_info = info->cap_info;
> > + memcpy(param->bssid, info->bssid, 6);
> > + memcpy((u8 *)param->ssid, info->ssid, info->ssid_len + 1);
> > + param->ssid_len = info->ssid_len;
> > + memset(param->rsn_pcip_policy, 0xFF, 3);
> > + memset(param->rsn_auth_policy, 0xFF, 3);
> > +
> > + while (index < info->ies_len)
> > + host_int_fill_join_bss_param(param, info->ies,
> > &index,
> > + &pcipher_total_cnt,
> > + &auth_total_cnt,
> > info->tsf_lo);
> > return (void *)param;
> > }
> >
next prev parent reply other threads:[~2018-05-09 18:43 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-07 8:43 [PATCH 00/30] staging: wilc1000: checkpatch fixes and code cleanup Ajay Singh
2018-05-07 8:43 ` [PATCH 01/30] staging: wilc1000: added complete() call for error scenario in handle_key() Ajay Singh
2018-05-07 8:43 ` [PATCH 02/30] staging: wilc1000: remove 'ret' variable " Ajay Singh
2018-05-07 8:43 ` [PATCH 03/30] staging: wilc1000: fix line over 80 chars " Ajay Singh
2018-05-09 13:44 ` Claudiu Beznea
2018-05-09 18:36 ` Ajay Singh
2018-05-10 5:21 ` Claudiu Beznea
2018-05-15 8:22 ` Dan Carpenter
2018-05-07 8:43 ` [PATCH 04/30] staging: wilc1000: fix line over 80 characters issue in handle_connect() Ajay Singh
2018-05-07 8:43 ` [PATCH 05/30] staging: wilc1000: fix line over 80 chars in host_int_parse_assoc_resp_info() Ajay Singh
2018-05-09 13:44 ` Claudiu Beznea
2018-05-09 18:59 ` Ajay Singh
2018-05-07 8:43 ` [PATCH 06/30] staging: wilc1000: fix line over 80 chars issue in host_int_handle_disconnect() Ajay Singh
2018-05-09 13:44 ` Claudiu Beznea
2018-05-09 18:33 ` Ajay Singh
2018-05-07 8:43 ` [PATCH 07/30] staging: wilc1000: fix line over 80 characters in host_int_parse_join_bss_param() Ajay Singh
2018-05-09 13:43 ` Claudiu Beznea
2018-05-09 18:41 ` Ajay Singh [this message]
2018-05-07 8:43 ` [PATCH 08/30] staging: wilc1000: fix line over 80 chars in host_int_parse_assoc_resp_info() Ajay Singh
2018-05-09 13:43 ` Claudiu Beznea
2018-05-09 18:41 ` Ajay Singh
2018-05-07 8:43 ` [PATCH 09/30] staging: wilc1000: rename kmalloc with kmemdup() in handle_connect_timeout() Ajay Singh
2018-05-07 8:43 ` [PATCH 10/30] staging: wilc1000: fix line over 80 chars in linux_mon Ajay Singh
2018-05-07 8:43 ` [PATCH 11/30] staging: wilc1000: use sizeof(*wdev) to allocate memory in wilc_wfi_cfg_alloc() Ajay Singh
2018-05-07 8:43 ` [PATCH 12/30] staging: wilc1000: use kmalloc(sizeof(*mgmt_tx)...) in mgmt_tx() Ajay Singh
2018-05-07 8:43 ` [PATCH 13/30] staging: wilc1000: rename clear_duringIP() to avoid camelCase issue Ajay Singh
2018-05-09 13:43 ` Claudiu Beznea
2018-05-07 8:43 ` [PATCH 14/30] staging: wilc1000: fix line over 80 chars in add_network_to_shadow() Ajay Singh
2018-05-09 13:43 ` Claudiu Beznea
2018-05-09 18:42 ` Ajay Singh
2018-05-10 5:27 ` Claudiu Beznea
2018-05-14 8:57 ` Claudiu Beznea
2018-05-14 11:18 ` Ajay Singh
2018-05-07 8:43 ` [PATCH 15/30] staging: wilc1000: use kmemdup instead of kmalloc " Ajay Singh
2018-05-09 13:42 ` Claudiu Beznea
2018-05-09 19:17 ` Ajay Singh
2018-05-10 5:35 ` Claudiu Beznea
2018-05-10 7:47 ` Ajay Singh
2018-05-07 8:43 ` [PATCH 16/30] staging: wilc1000: fix line over 80 charas in wilc_wfi_remain_on_channel_expired() Ajay Singh
2018-05-07 8:43 ` [PATCH 17/30] staging: wilc1000: fix line over 80 chars in wilc_wfi_cfg_tx_vendor_spec() Ajay Singh
2018-05-09 13:42 ` Claudiu Beznea
2018-05-09 18:44 ` Ajay Singh
2018-05-07 8:43 ` [PATCH 18/30] staging: wilc1000: fix line over 80 chars in get_station() Ajay Singh
2018-05-07 8:43 ` [PATCH 19/30] staging: wilc1000: fix line over 80 chars in wilc_create_wiphy() declaration Ajay Singh
2018-05-07 8:43 ` [PATCH 20/30] staging: wilc1000: fix line over 80 characters in add_key() Ajay Singh
2018-05-07 8:43 ` [PATCH 21/30] staging: wilc1000: fix line over 80 chars in scan() Ajay Singh
2018-05-07 8:43 ` [PATCH 22/30] staging: wilc1000: fix line over 80 chars issue in connect() Ajay Singh
2018-05-07 8:43 ` [PATCH 23/30] staging: wilc1000: rename u8security to avoid datatype in variable name Ajay Singh
2018-05-07 8:43 ` [PATCH 24/30] staging: wilc1000: refactor del_station() to avoid parenthesis misalignment Ajay Singh
2018-05-15 9:01 ` Dan Carpenter
2018-05-15 11:46 ` Ajay Singh
2018-05-07 8:43 ` [PATCH 25/30] staging: wilc1000: fix line over 80 chars in wilc_sdio struct Ajay Singh
2018-05-07 8:43 ` [PATCH 26/30] staging: wilc1000: added #define for setting radiotap header Ajay Singh
2018-05-07 8:43 ` [PATCH 27/30] staging: wilc1000: remove 'flag' argument from wilc_mac_indicate() Ajay Singh
2018-05-07 8:43 ` [PATCH 28/30] staging: wilc1000: added comments for mutex and spinlock_t Ajay Singh
2018-05-09 13:42 ` Claudiu Beznea
2018-05-07 8:43 ` [PATCH 29/30] staging: wilc1000: remove unused 'lock' varible in 'wilc_priv' structure Ajay Singh
2018-05-07 8:43 ` [PATCH 30/30] staging: wilc1000: rename s8idxarray to avoid datatype in variable name Ajay Singh
2018-05-09 13:42 ` Claudiu Beznea
2018-05-09 18:44 ` Ajay Singh
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=20180510001117.26a29f19@ajaysk-VirtualBox \
--to=ajay.kathat@microchip.com \
--cc=Claudiu.Beznea@microchip.com \
--cc=adham.abozaeid@Microchip.com \
--cc=aditya.shankar@microchip.com \
--cc=devel@driverdev.osuosl.org \
--cc=ganesh.krishna@microchip.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-wireless@vger.kernel.org \
--cc=venkateswara.kaja@microchip.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;
as well as URLs for NNTP newsgroup(s).