* [PATCH 1/6] staging: rtl8723bs: replace while with shorter for loop
@ 2018-07-08 10:38 Michael Straube
2018-07-08 10:38 ` [PATCH 2/6] staging: rtl8723bs: replace tab with space Michael Straube
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Michael Straube @ 2018-07-08 10:38 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Simplify rtw_get_rateset_len() by replacing the while loop
with a shorter for loop.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 8e0025e1ff14..9b60e0214bd8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -298,17 +298,11 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode)
uint rtw_get_rateset_len(u8 *rateset)
{
- uint i = 0;
+ uint i;
- while (1) {
- if ((rateset[i]) == 0)
- break;
-
- if (i > 12)
+ for (i = 0; i < 13; i++)
+ if (rateset[i] == 0)
break;
-
- i++;
- }
return i;
}
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/6] staging: rtl8723bs: replace tab with space
2018-07-08 10:38 [PATCH 1/6] staging: rtl8723bs: replace while with shorter for loop Michael Straube
@ 2018-07-08 10:38 ` Michael Straube
2018-07-08 10:38 ` [PATCH 3/6] staging: rtl8723bs: fix indentation Michael Straube
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Michael Straube @ 2018-07-08 10:38 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Replace tabs with spaces in some function definitions.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 9b60e0214bd8..429ec929fa1a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -67,7 +67,7 @@ int rtw_get_bit_value_from_ieee_value(u8 val)
return 0;
}
-uint rtw_is_cckrates_included(u8 *rate)
+uint rtw_is_cckrates_included(u8 *rate)
{
u32 i = 0;
@@ -81,7 +81,7 @@ uint rtw_is_cckrates_included(u8 *rate)
return false;
}
-uint rtw_is_cckratesonly_included(u8 *rate)
+uint rtw_is_cckratesonly_included(u8 *rate)
{
u32 i = 0;
@@ -296,7 +296,7 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode)
}
}
-uint rtw_get_rateset_len(u8 *rateset)
+uint rtw_get_rateset_len(u8 *rateset)
{
uint i;
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/6] staging: rtl8723bs: fix indentation
2018-07-08 10:38 [PATCH 1/6] staging: rtl8723bs: replace while with shorter for loop Michael Straube
2018-07-08 10:38 ` [PATCH 2/6] staging: rtl8723bs: replace tab with space Michael Straube
@ 2018-07-08 10:38 ` Michael Straube
2018-07-08 16:46 ` Joe Perches
2018-07-08 10:38 ` [PATCH 4/6] staging: rtl8723bs: remove blank lines Michael Straube
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Michael Straube @ 2018-07-08 10:38 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Remove unrequired extra indentations.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 429ec929fa1a..adf216de113b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -69,16 +69,16 @@ int rtw_get_bit_value_from_ieee_value(u8 val)
uint rtw_is_cckrates_included(u8 *rate)
{
- u32 i = 0;
+ u32 i = 0;
- while (rate[i] != 0) {
- if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
- (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
- return true;
- i++;
- }
+ while (rate[i] != 0) {
+ if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
+ (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
+ return true;
+ i++;
+ }
- return false;
+ return false;
}
uint rtw_is_cckratesonly_included(u8 *rate)
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/6] staging: rtl8723bs: remove blank lines
2018-07-08 10:38 [PATCH 1/6] staging: rtl8723bs: replace while with shorter for loop Michael Straube
2018-07-08 10:38 ` [PATCH 2/6] staging: rtl8723bs: replace tab with space Michael Straube
2018-07-08 10:38 ` [PATCH 3/6] staging: rtl8723bs: fix indentation Michael Straube
@ 2018-07-08 10:38 ` Michael Straube
2018-07-08 10:38 ` [PATCH 5/6] staging: rtl8723bs: add missing " Michael Straube
2018-07-08 10:38 ` [PATCH 6/6] staging: rtl8723bs: remove braces from single if statement Michael Straube
4 siblings, 0 replies; 11+ messages in thread
From: Michael Straube @ 2018-07-08 10:38 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Remove unrequired blank lines as reported by checkpatch.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
.../staging/rtl8723bs/core/rtw_ieee80211.c | 31 -------------------
1 file changed, 31 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index adf216de113b..ab1174f7c83a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -53,11 +53,9 @@ static u8 WIFI_OFDMRATES[] = {
IEEE80211_OFDM_RATE_54MB
};
-
int rtw_get_bit_value_from_ieee_value(u8 val)
{
unsigned char dot11_rate_table[] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; /* last element must be zero!! */
-
int i = 0;
while (dot11_rate_table[i] != 0) {
if (dot11_rate_table[i] == val)
@@ -85,7 +83,6 @@ uint rtw_is_cckratesonly_included(u8 *rate)
{
u32 i = 0;
-
while (rate[i] != 0) {
if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
(((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
@@ -111,7 +108,6 @@ int rtw_check_network_type(unsigned char *rate, int ratelen, int channel)
else
return WIRELESS_11G;
}
-
}
u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source,
@@ -191,7 +187,6 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u
uint cnt;
u8 *target_ie = NULL;
-
if (ielen)
*ielen = 0;
@@ -215,7 +210,6 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u
} else{
cnt += in_ie[cnt+1]+2; /* goto next */
}
-
}
return target_ie;
@@ -292,7 +286,6 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode)
memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
break;
-
}
}
@@ -363,7 +356,6 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
/* DS parameter set */
ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz);
-
/* IBSS Parameter Set */
ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz);
@@ -398,10 +390,8 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new);
if (pbuf) {
-
/* check if oui matches... */
if (memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type))) {
-
goto check_next_ie;
}
@@ -417,7 +407,6 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
return pbuf;
} else{
-
*wpa_ie_len = 0;
return NULL;
}
@@ -430,20 +419,16 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
break;
pbuf += (2 + len);
-
}
*wpa_ie_len = 0;
return NULL;
-
}
unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit)
{
-
return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
-
}
int rtw_get_wpa_cipher_suite(u8 *s)
@@ -478,7 +463,6 @@ int rtw_get_wpa2_cipher_suite(u8 *s)
return 0;
}
-
int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
{
int i, ret = _SUCCESS;
@@ -491,7 +475,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
return _FAIL;
}
-
if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) ||
(memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) {
return _FAIL;
@@ -502,10 +485,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
pos += 8;
left = wpa_ie_len - 8;
-
/* group_cipher */
if (left >= WPA_SELECTOR_LEN) {
-
*group_cipher = rtw_get_wpa_cipher_suite(pos);
pos += WPA_SELECTOR_LEN;
@@ -517,7 +498,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
return _FAIL;
}
-
/* pairwise_cipher */
if (left >= 2) {
/* count = le16_to_cpu(*(u16*)pos); */
@@ -554,7 +534,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
}
return ret;
-
}
int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
@@ -569,7 +548,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
return _FAIL;
}
-
if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) {
return _FAIL;
}
@@ -580,7 +558,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
/* group_cipher */
if (left >= RSN_SELECTOR_LEN) {
-
*group_cipher = rtw_get_wpa2_cipher_suite(pos);
pos += RSN_SELECTOR_LEN;
@@ -628,7 +605,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
}
return ret;
-
}
/* ifdef CONFIG_WAPI_SUPPORT */
@@ -730,7 +706,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie,
cnt += in_ie[cnt+1]+2; /* get next */
}
}
-
}
return (*rsn_len + *wpa_len);
@@ -795,7 +770,6 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
} else{
cnt += in_ie[cnt+1]+2; /* goto next */
}
-
}
return wpsie_ptr;
@@ -848,7 +822,6 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att
} else{
attr_ptr += attr_len; /* goto next */
}
-
}
return target_attr_ptr;
@@ -981,7 +954,6 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
}
return 0;
-
}
/**
@@ -1128,7 +1100,6 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
return ParseFailed;
return unknown ? ParseUnknown : ParseOK;
-
}
void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
@@ -1173,7 +1144,6 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
if (pbuf && (wpa_ielen > 0)) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen));
if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) {
-
pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher;
pnetwork->BcnInfo.group_cipher = group_cipher;
pnetwork->BcnInfo.is_8021x = is8021x;
@@ -1182,7 +1152,6 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
ret = _SUCCESS;
}
} else {
-
pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen > 0)) {
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/6] staging: rtl8723bs: add missing blank lines
2018-07-08 10:38 [PATCH 1/6] staging: rtl8723bs: replace while with shorter for loop Michael Straube
` (2 preceding siblings ...)
2018-07-08 10:38 ` [PATCH 4/6] staging: rtl8723bs: remove blank lines Michael Straube
@ 2018-07-08 10:38 ` Michael Straube
2018-07-08 10:38 ` [PATCH 6/6] staging: rtl8723bs: remove braces from single if statement Michael Straube
4 siblings, 0 replies; 11+ messages in thread
From: Michael Straube @ 2018-07-08 10:38 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Add missing blank lines after declarations as reported by checkpatch.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index ab1174f7c83a..a4f9e2b90b08 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -57,6 +57,7 @@ int rtw_get_bit_value_from_ieee_value(u8 val)
{
unsigned char dot11_rate_table[] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; /* last element must be zero!! */
int i = 0;
+
while (dot11_rate_table[i] != 0) {
if (dot11_rate_table[i] == val)
return BIT(i);
@@ -1139,6 +1140,7 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
unsigned char *pbuf;
int group_cipher = 0, pairwise_cipher = 0, is8021x = 0;
int ret = _FAIL;
+
pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen > 0)) {
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/6] staging: rtl8723bs: remove braces from single if statement
2018-07-08 10:38 [PATCH 1/6] staging: rtl8723bs: replace while with shorter for loop Michael Straube
` (3 preceding siblings ...)
2018-07-08 10:38 ` [PATCH 5/6] staging: rtl8723bs: add missing " Michael Straube
@ 2018-07-08 10:38 ` Michael Straube
4 siblings, 0 replies; 11+ messages in thread
From: Michael Straube @ 2018-07-08 10:38 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Remove braces from single if statement to follow kernel coding style.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index a4f9e2b90b08..3f1c7bb0eb9f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -149,9 +149,8 @@ u8 *rtw_get_ie(u8 *pbuf, sint index, sint *len, sint limit)
sint tmp, i;
u8 *p;
- if (limit < 1) {
+ if (limit < 1)
return NULL;
- }
p = pbuf;
i = 0;
--
2.18.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] staging: rtl8723bs: fix indentation
2018-07-08 10:38 ` [PATCH 3/6] staging: rtl8723bs: fix indentation Michael Straube
@ 2018-07-08 16:46 ` Joe Perches
2018-07-08 17:36 ` Michael Straube
0 siblings, 1 reply; 11+ messages in thread
From: Joe Perches @ 2018-07-08 16:46 UTC (permalink / raw)
To: Michael Straube, gregkh; +Cc: devel, linux-kernel
On Sun, 2018-07-08 at 12:38 +0200, Michael Straube wrote:
> Remove unrequired extra indentations.
[]
> diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
[]
> @@ -69,16 +69,16 @@ int rtw_get_bit_value_from_ieee_value(u8 val)
>
> uint rtw_is_cckrates_included(u8 *rate)
> {
> - u32 i = 0;
> + u32 i = 0;
>
> - while (rate[i] != 0) {
> - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
> - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
> - return true;
> - i++;
> - }
> + while (rate[i] != 0) {
> + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
> + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
> + return true;
> + i++;
> + }
>
> - return false;
> + return false;
> }
Hi Michael.
Please try to improve the code for human readers and/or
reduce overall object size over merely shutting up checkpatch
style warnings.
For instance:
You could reduce object size a little by eliminating the
multiple use of 0x7f and index and dereferencing the
pointer instead.
$ size drivers/staging/rtl8723bs/core/rtw_ieee80211.o*
text data bss dec hex filename
10085 76 0 10161 27b1 drivers/staging/rtl8723bs/core/rtw_ieee80211.o.new
10149 76 0 10225 27f1 drivers/staging/rtl8723bs/core/rtw_ieee80211.o.old
Something like:
uint rtw_is_cckrates_included(u8 *rate)
{
while (*rate) {
u8 r = *rate & 0x7f;
if (r == 2 || r == 4 || r == 11 || r == 22)
return true;
rate++;
}
return false;
}
uint rtw_is_cckratesonly_included(u8 *rate)
{
while (*rate) {
u8 r = *rate & 0x7f;
if (r != 2 && r != 4 && r != 11 && r != 22)
return false;
rate++;
}
return true;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] staging: rtl8723bs: fix indentation
2018-07-08 16:46 ` Joe Perches
@ 2018-07-08 17:36 ` Michael Straube
2018-07-11 13:57 ` Michael Straube
0 siblings, 1 reply; 11+ messages in thread
From: Michael Straube @ 2018-07-08 17:36 UTC (permalink / raw)
To: Joe Perches, gregkh; +Cc: devel, linux-kernel
On 07/08/18 18:46, Joe Perches wrote:
> On Sun, 2018-07-08 at 12:38 +0200, Michael Straube wrote:
>> Remove unrequired extra indentations.
> []
>> diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> []
>> @@ -69,16 +69,16 @@ int rtw_get_bit_value_from_ieee_value(u8 val)
>>
>> uint rtw_is_cckrates_included(u8 *rate)
>> {
>> - u32 i = 0;
>> + u32 i = 0;
>>
>> - while (rate[i] != 0) {
>> - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
>> - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
>> - return true;
>> - i++;
>> - }
>> + while (rate[i] != 0) {
>> + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
>> + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
>> + return true;
>> + i++;
>> + }
>>
>> - return false;
>> + return false;
>> }
>
> Hi Michael.
>
> Please try to improve the code for human readers and/or
> reduce overall object size over merely shutting up checkpatch
> style warnings.
>
Hi Joe,
I agree that it's better to improve the code than just silence
warnings.
Thanks for your advice.
> For instance:
>
> You could reduce object size a little by eliminating the
> multiple use of 0x7f and index and dereferencing the
> pointer instead.
>
> $ size drivers/staging/rtl8723bs/core/rtw_ieee80211.o*
> text data bss dec hex filename
> 10085 76 0 10161 27b1 drivers/staging/rtl8723bs/core/rtw_ieee80211.o.new
> 10149 76 0 10225 27f1 drivers/staging/rtl8723bs/core/rtw_ieee80211.o.old
>
> Something like:
>
> uint rtw_is_cckrates_included(u8 *rate)
> {
> while (*rate) {
> u8 r = *rate & 0x7f;
>
> if (r == 2 || r == 4 || r == 11 || r == 22)
> return true;
> rate++;
> }
>
> return false;
> }
>
> uint rtw_is_cckratesonly_included(u8 *rate)
> {
> while (*rate) {
> u8 r = *rate & 0x7f;
>
> if (r != 2 && r != 4 && r != 11 && r != 22)
> return false;
> rate++;
> }
>
> return true;
> }
>
The patch has been added to staging-testing already.
I will send patches with your suggestions the next days.
Thanks again.
Michael
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] staging: rtl8723bs: fix indentation
2018-07-08 17:36 ` Michael Straube
@ 2018-07-11 13:57 ` Michael Straube
2018-07-11 16:03 ` Joe Perches
0 siblings, 1 reply; 11+ messages in thread
From: Michael Straube @ 2018-07-11 13:57 UTC (permalink / raw)
To: Joe Perches, gregkh; +Cc: devel, linux-kernel
On 07/08/18 19:36, Michael Straube wrote:
> On 07/08/18 18:46, Joe Perches wrote:
>> On Sun, 2018-07-08 at 12:38 +0200, Michael Straube wrote:
>>
>> uint rtw_is_cckratesonly_included(u8 *rate)
>> {
>> while (*rate) {
>> u8 r = *rate & 0x7f;
>>
>> if (r != 2 && r != 4 && r != 11 && r != 22)
>> return false;
>> rate++;
>> }
>>
>> return true;
>> }
>>
>
> The patch has been added to staging-testing already.
> I will send patches with your suggestions the next days.
Would it be preferred to declare the variable at the functions beginning,
or doesn't it matter regarding coding style?
uint rtw_is_cckratesonly_included(u8 *rate)
{
u8 r;
while (*rate) {
r = *rate & 0x7f;
...
Best,
Michael
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] staging: rtl8723bs: fix indentation
2018-07-11 13:57 ` Michael Straube
@ 2018-07-11 16:03 ` Joe Perches
2018-07-11 19:17 ` Michael Straube
0 siblings, 1 reply; 11+ messages in thread
From: Joe Perches @ 2018-07-11 16:03 UTC (permalink / raw)
To: Michael Straube, gregkh; +Cc: devel, linux-kernel
On Wed, 2018-07-11 at 15:57 +0200, Michael Straube wrote:
> On 07/08/18 19:36, Michael Straube wrote:
> > On 07/08/18 18:46, Joe Perches wrote:
> > > On Sun, 2018-07-08 at 12:38 +0200, Michael Straube wrote:
> > >
> > > uint rtw_is_cckratesonly_included(u8 *rate)
> > > {
> > > while (*rate) {
> > > u8 r = *rate & 0x7f;
> > >
> > > if (r != 2 && r != 4 && r != 11 && r != 22)
> > > return false;
> > > rate++;
> > > }
> > >
> > > return true;
> > > }
> > >
> >
> > The patch has been added to staging-testing already.
> > I will send patches with your suggestions the next days.
>
> Would it be preferred to declare the variable at the functions beginning,
> or doesn't it matter regarding coding style?
Not really.
It's generally preferred to have declarations in the
nearest possible open brace to allow the compiler to
reduce the overall stack space consumed by the function.
For example prefer:
int some_function(int arg, void *pointer)
{
if (arg == 1} {
struct foo a = *(struct foo *)pointer;
...
} else if (arg == 2) {
struct bar b = *(struct bar *)pointer;
...
}
}
over
int some_function(int arg, void *pointer)
{
struct foo a;
s
truct bar b;
if (arg == 1} {
a = *(struct foo *)pointer;
...
} else if (arg == 2) {
b = *(struct bar *)pointer;
...
}
}
as a and b could use the same stack in the
first example but not the second.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/6] staging: rtl8723bs: fix indentation
2018-07-11 16:03 ` Joe Perches
@ 2018-07-11 19:17 ` Michael Straube
0 siblings, 0 replies; 11+ messages in thread
From: Michael Straube @ 2018-07-11 19:17 UTC (permalink / raw)
To: Joe Perches, gregkh; +Cc: devel, linux-kernel
On 07/11/18 18:03, Joe Perches wrote:
> On Wed, 2018-07-11 at 15:57 +0200, Michael Straube wrote:
>> On 07/08/18 19:36, Michael Straube wrote:
>>> On 07/08/18 18:46, Joe Perches wrote:
>>>> On Sun, 2018-07-08 at 12:38 +0200, Michael Straube wrote:
>>>>
>>>> uint rtw_is_cckratesonly_included(u8 *rate)
>>>> {
>>>> while (*rate) {
>>>> u8 r = *rate & 0x7f;
>>>>
>>>> if (r != 2 && r != 4 && r != 11 && r != 22)
>>>> return false;
>>>> rate++;
>>>> }
>>>>
>>>> return true;
>>>> }
>>>>
>>>
>>> The patch has been added to staging-testing already.
>>> I will send patches with your suggestions the next days.
>>
>> Would it be preferred to declare the variable at the functions beginning,
>> or doesn't it matter regarding coding style?
>
> Not really.
>
> It's generally preferred to have declarations in the
> nearest possible open brace to allow the compiler to
> reduce the overall stack space consumed by the function.
>
> For example prefer:
>
> int some_function(int arg, void *pointer)
> {
> if (arg == 1} {
> struct foo a = *(struct foo *)pointer;
> ...
> } else if (arg == 2) {
> struct bar b = *(struct bar *)pointer;
> ...
> }
> }
>
> over
>
> int some_function(int arg, void *pointer)
> {
> struct foo a;
> s
> truct bar b;
>
> if (arg == 1} {
> a = *(struct foo *)pointer;
> ...
> } else if (arg == 2) {
> b = *(struct bar *)pointer;
> ...
> }
> }
>
> as a and b could use the same stack in the
> first example but not the second.
>
Ok, thanks for explaining.
Michael
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-07-11 19:17 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-08 10:38 [PATCH 1/6] staging: rtl8723bs: replace while with shorter for loop Michael Straube
2018-07-08 10:38 ` [PATCH 2/6] staging: rtl8723bs: replace tab with space Michael Straube
2018-07-08 10:38 ` [PATCH 3/6] staging: rtl8723bs: fix indentation Michael Straube
2018-07-08 16:46 ` Joe Perches
2018-07-08 17:36 ` Michael Straube
2018-07-11 13:57 ` Michael Straube
2018-07-11 16:03 ` Joe Perches
2018-07-11 19:17 ` Michael Straube
2018-07-08 10:38 ` [PATCH 4/6] staging: rtl8723bs: remove blank lines Michael Straube
2018-07-08 10:38 ` [PATCH 5/6] staging: rtl8723bs: add missing " Michael Straube
2018-07-08 10:38 ` [PATCH 6/6] staging: rtl8723bs: remove braces from single if statement Michael Straube
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).