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
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel