lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190403161803.GE32590@kadam>
Date:   Wed, 3 Apr 2019 19:18:03 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Madhumitha Prabakaran <madhumithabiw@...il.com>
Cc:     gregkh@...uxfoundation.org, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Staging: rtlwifi: Remove unwanted parentheses

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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ