[PATCH 05/11] staging: comedi: core: initialize subdevice s->io_bits in postconfig
Dan Carpenter
dan.carpenter at oracle.com
Fri Aug 30 08:23:51 UTC 2013
On Thu, Aug 29, 2013 at 04:43:49PM +0000, Hartley Sweeten wrote:
> > You don't really need to test s->n_chan < 32. For s->n_chan >= 32,
> > s->io_bits will end up set to 0xffffffff anyway (and for s->n_chan > 32,
> > the low-level drivers shouldn't really be using s->state and s->io_bits
> > anyway).
>
> I wasn't sure about that. 1 << 32 overflows the unsigned int to 0x100000000.
> But I guess the 32-bit portion (0x00000000) - 1 is still 0xffffffff.
>
Nope. Shift wrapping doesn't work like that. Here is how it works in
GCC.
int maint(void)
{
int a, b, shift;
a = 1 << 32; /* a is zero */
shift = 32;
b = 1 << shift; /* b wraps to 1 */
printf("%x %x\n", a, b);
}
regards,
dan carpenter
More information about the devel
mailing list