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] [day] [month] [year] [list]
Date:   Sun, 11 Sep 2016 00:54:30 +0530
From:   Bhumika Goyal <bhumirks@...il.com>
To:     Joe Perches <joe@...ches.com>
Cc:     wsa@...-dreams.de, linux-i2c@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Drivers: i2c: busses: Use max macro instead of ternary operator

On Sun, Sep 11, 2016 at 12:51 AM, Joe Perches <joe@...ches.com> wrote:
> On Sun, 2016-09-11 at 00:38 +0530, Bhumika Goyal wrote:
>> Replace ternary operators with macro 'max' as it is shorter
>> and thus increases code readability. Macro max returns
>> the  maximum of the two compared values.
>> Done using coccinelle:
>>
>> @@
>> type T;
>> T x;
>> T y;
>> @@
>> (
>> - x < y ? x : y
>> + min(x,y)
>> - x > y ? x : y
>> + max(x,y)
>> )
>
> Hello.
>
> Please make sure to inspect and if appropriate modify the coccinelle
> output for the 'best' coding style, for whatever definition of 'best'
> you might use, before submitting automatically produced patches.
>
>> diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c
> []
>> @@ -133,10 +133,10 @@ static const char * const jz4780_i2c_abrt_src[] = {
>>
>> #define JZ4780_I2C_ENB_I2C            BIT(0)
>>
>> -#define JZ4780_I2CSHCNT_ADJUST(n)    (((n) - 8) < 6 ? 6 : ((n) - 8))
>> -#define JZ4780_I2CSLCNT_ADJUST(n)    (((n) - 1) < 8 ? 8 : ((n) - 1))
>> -#define JZ4780_I2CFHCNT_ADJUST(n)    (((n) - 8) < 6 ? 6 : ((n) - 8))
>> -#define JZ4780_I2CFLCNT_ADJUST(n)    (((n) - 1) < 8 ? 8 : ((n) - 1))
>> +#define JZ4780_I2CSHCNT_ADJUST(n)    (max(6, (n) - 8))
>> +#define JZ4780_I2CSLCNT_ADJUST(n)    (max(8, (n) - 1))
>> +#define JZ4780_I2CFHCNT_ADJUST(n)    (max(6, (n) - 8))
>> +#define JZ4780_I2CFLCNT_ADJUST(n)    (max(8, (n) - 1))
>
> For instance: the parentheses are unnecessary and could be removed
> like the BIT macro above.

Thanks for pointing it out. I will resend the patch.

Thanks,
Bhumika
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ