2018-06-16 06:01:38

by Hyunil Kim

[permalink] [raw]
Subject: [PATCH] staging: rtl8192u: fix line over 80 characters

*fix checkpatch.pl warnings:
WARNING: line over 80 characters

Signed-off-by: Hyunil Kim <[email protected]>
---
drivers/staging/rtl8192u/r8192U_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 74c5865..2111e01 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2044,7 +2044,10 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
return false;
} else if ((wpa_ie_len != 0)) {
/* parse pairwise key type */
- if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
+ if (((ieee->wpa_ie[0] == 0xdd) &&
+ (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) ||
+ ((ieee->wpa_ie[0] == 0x30) &&
+ (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
return true;
else
return false;
--
2.7.4




2018-06-16 06:03:58

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8192u: fix line over 80 characters



On Sat, 16 Jun 2018, Hyunil Kim wrote:

> *fix checkpatch.pl warnings:
> WARNING: line over 80 characters

Describe what you do and why, rather than just saying "Fix". Often
something can be fixed in multiple ways.

julia

>
> Signed-off-by: Hyunil Kim <[email protected]>
> ---
> drivers/staging/rtl8192u/r8192U_core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 74c5865..2111e01 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -2044,7 +2044,10 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
> return false;
> } else if ((wpa_ie_len != 0)) {
> /* parse pairwise key type */
> - if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
> + if (((ieee->wpa_ie[0] == 0xdd) &&
> + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) ||
> + ((ieee->wpa_ie[0] == 0x30) &&
> + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
> return true;
> else
> return false;
> --
> 2.7.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2018-06-16 19:22:49

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8192u: fix line over 80 characters

On Sat, 16 Jun 2018 15:00:31 +0900, Hyunil Kim said:
> *fix checkpatch.pl warnings:
> WARNING: line over 80 characters

> + if (((ieee->wpa_ie[0] == 0xdd) &&
> + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) ||
> + ((ieee->wpa_ie[0] == 0x30) &&
> + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))

Ouch. The && and || at ends of line mean a lot of parenthesis counting to
figure out which goes with which. Use additional indentation to help
understanding.

+ if (((ieee->wpa_ie[0] == 0xdd) &&
+ (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) ||
+ ((ieee->wpa_ie[0] == 0x30) &&
+ (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))

Or perhaps

+ if (((ieee->wpa_ie[0] == 0xdd) &&
+ (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4)))
+ || ((ieee->wpa_ie[0] == 0x30) &&
+ (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))




Attachments:
(No filename) (497.00 B)

2018-06-16 23:15:10

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8192u: fix line over 80 characters

On Sat, 2018-06-16 at 15:22 -0400, [email protected] wrote:
> On Sat, 16 Jun 2018 15:00:31 +0900, Hyunil Kim said:
> > *fix checkpatch.pl warnings:
> > WARNING: line over 80 characters
> > + if (((ieee->wpa_ie[0] == 0xdd) &&
> > + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) ||
> > + ((ieee->wpa_ie[0] == 0x30) &&
> > + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
>
> Ouch. The && and || at ends of line mean a lot of parenthesis counting to
> figure out which goes with which. Use additional indentation to help
> understanding.
>
> + if (((ieee->wpa_ie[0] == 0xdd) &&
> + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) ||
> + ((ieee->wpa_ie[0] == 0x30) &&
> + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
>
> Or perhaps
>
> + if (((ieee->wpa_ie[0] == 0xdd) &&
> + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4)))
> + || ((ieee->wpa_ie[0] == 0x30) &&
> + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))

Or perhaps refactor to something like:
---
drivers/staging/rtl8192u/r8192U_core.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 8b17400f6c13..593ecc0ae1ae 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2039,20 +2039,18 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
(strcmp(crypt->ops->name, "WEP") == 0));

/* simply judge */
- if (encrypt && (wpa_ie_len == 0)) {
- /* wep encryption, no N mode setting */
+ /* wep encryption, no N mode setting */
+ if (encrypt && wpa_ie_len == 0)
return false;
- } else if ((wpa_ie_len != 0)) {
- /* parse pairwise key type */
- if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
- return true;
- else
- return false;
- } else {
+
+ if (wpa_ie_len == 0)
return true;
- }

- return true;
+ /* parse pairwise key type */
+ return (ieee->wpa_ie[0] == 0xdd &&
+ !memcmp(&ieee->wpa_ie[14], ccmp_ie, 4)) ||
+ (ieee->wpa_ie[0] == 0x30 &&
+ !memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4));
}

static bool GetHalfNmodeSupportByAPs819xUsb(struct net_device *dev)