mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: valdis.kletnieks@vt.edu, Hyunil Kim <thtlwlsmsgkfla@gmail.com>
Cc: gregkh@linuxfoundation.org, davem@davemloft.net,
	colin.king@canonical.com, johannes.berg@intel.com,
	Linyu.Yuan@alcatel-sbell.com.cn, keescook@chromium.org,
	tvboxspy@gmail.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8192u: fix line over 80 characters
Date: Sat, 16 Jun 2018 16:13:59 -0700	[thread overview]
Message-ID: <5ad0ea84d5b8733e7bb7a647e185f2577c073cf5.camel@perches.com> (raw)
In-Reply-To: <127735.1529176927@turing-police.cc.vt.edu>

On Sat, 2018-06-16 at 15:22 -0400, valdis.kletnieks@vt.edu 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)


      reply	other threads:[~2018-06-16 23:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-16  6:00 Hyunil Kim
2018-06-16  6:03 ` Julia Lawall
2018-06-16 19:22 ` valdis.kletnieks
2018-06-16 23:13   ` Joe Perches [this message]

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=5ad0ea84d5b8733e7bb7a647e185f2577c073cf5.camel@perches.com \
    --to=joe@perches.com \
    --cc=Linyu.Yuan@alcatel-sbell.com.cn \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes.berg@intel.com \
    --cc=keescook@chromium.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thtlwlsmsgkfla@gmail.com \
    --cc=tvboxspy@gmail.com \
    --cc=valdis.kletnieks@vt.edu \
    /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®