From: Dan Carpenter <dan.carpenter@oracle.com>
To: Madhumitha Prabakaran <madhumithabiw@gmail.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Staging: rtlwifi: Remove unwanted parentheses
Date: Wed, 3 Apr 2019 19:18:03 +0300 [thread overview]
Message-ID: <20190403161803.GE32590@kadam> (raw)
In-Reply-To: <20190403160445.11110-1-madhumithabiw@gmail.com>
On Wed, Apr 03, 2019 at 11:04:45AM -0500, Madhumitha Prabakaran wrote:
> Remove unwanted parentheses around right hand side of an assignment to
> make code better and more understandable.
>
> Issue found by Coccinelle.
>
> Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
> ---
> drivers/staging/rtlwifi/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
> index a9902818ae7e..970343048b69 100644
> --- a/drivers/staging/rtlwifi/core.c
> +++ b/drivers/staging/rtlwifi/core.c
> @@ -341,8 +341,8 @@ static u16 crc16_ccitt(u8 data, u16 crc)
> u16 result;
>
> for (i = 0; i < 8; i++) {
> - crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
> - data_bit = (data & (BIT(0) << i) ? 1 : 0);
> + crc_bit15 = (crc & BIT(15)) ? 1 : 0;
> + data_bit = data & (BIT(0) << i) ? 1 : 0;
The original is obviously unhelpful, yes. And the code works correctly,
true. But my preferred format would be like this:
data_bit = (data & BIT(i)) ? 1 : 0;
Left shifting BIT() is silly. But I like the extra parentheses around
the bitwise AND operation because that's a hard precedence to remember.
regards,
dan carpenter
next prev parent reply other threads:[~2019-04-03 16:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 16:04 [PATCH] Staging: rtlwifi: Remove unwanted parentheses Madhumitha Prabakaran
2019-04-03 16:18 ` Dan Carpenter [this message]
2019-04-03 16:21 ` Dan Carpenter
2019-04-03 22:50 ` Madhumthia Prabakaran
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=20190403161803.GE32590@kadam \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madhumithabiw@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.