Re: [PATCH 1/2] Staging:iio:Prefer using BIT macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 8, 2016 at 11:14 AM, Lars-Peter Clausen <lars@xxxxxxxxxx> wrote:
> On 02/08/2016 07:48 AM, Bhumika Goyal wrote:

>>               value = (s8)((data >> AD7816_TEMP_FLOAT_OFFSET) - 103);
>>               data &= AD7816_TEMP_FLOAT_MASK;
>>               if (value < 0)
>> -                     data = (1 << AD7816_TEMP_FLOAT_OFFSET) - data;
>> +                     data = BIT(AD7816_TEMP_FLOAT_OFFSET) - data;
>
>
> But in this case this is a false positive. The intended semantic meaning
> here is 2**... not BIT(...). Using BIT() here in my opinion only causes
> confusion.

+1. Here clearly the intention is to change sign of the value which
fits less than 32/16/8 bits. 1 << OFFSET represents '-0'.

-- 
With Best Regards,
Andy Shevchenko
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux