Re: [PATCH 1/3] staging: comedi: comedi_bond: fix 'b_mask' calc in bonding_dio_insn_bits()

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

 



I knew the original was undefined because Ian showed me the relevant
section from the standard.  I'm actually surprised that it doesn't work
in GCC.  Using -fno-strict-overflow doesn't help either.  I think at the
optimizations that the kernel uses -O2 and -Os the original "works".

Anyway, the old code is definitely wrong.

But the new code is also undefined because we are subtracting from
INT_MIN.  I imagine how GCC could handle the undefined behavior in an
unexpected way so the new code is probably fine.  But we may as well
just be pedantic.

		b_mask = (b_chans < 32) ? ((1U << b_chans) - 1)
					: 0xffffffff;

regards,
dan carpenter

_______________________________________________
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