RE: Question about the function,ni_stc_dma_channel_select_bitfield

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

 



On Wednesday, May 06, 2015 7:06 AM, nick wrote:
> On 2015-05-06 05:10 AM, Ian Abbott wrote:
>> On 06/05/15 01:22, nick wrote:
>>> Greetings All,
>>> I am wondering if in the function,ni_stc_dma_channel_select_bitfield the line:
>>> return 1 << channel;
>>> is guaranteed to be below the threshold that guarantees us to not overflow on
>>> a unsigned 32 integer due to bit wise shifting to the left.
>>> Thanks Nick
>>>
>> 
>>     if (channel < 4)
>>         return 1 << channel;
>> 
>> So, yes.
>> 
> This should be commented in my option as this is not common knowledge
> unless you known the hardware specs really well. If I should send in
> a patch adding a comment here please let me known.

A comment is not necessary. The code explicitly states that channel (an unsigned var)
needs to be < 4 for the bit shift to happen.

Hartley
_______________________________________________
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