Re: [PATCH 10/27] drivers/infiniband/core: Use memdup_user

From: Roland Dreier
Date: Sat May 22 2010 - 11:16:03 EST


> > + data = memdup_user((void __user *)(unsigned long)src, len);
> > + if (IS_ERR(data))
> > + return PTR_ERR(data);

> This cast look strange, can it happen that (unsigned long)<(u64) ?
> (is there a 32bit infiniband) ?

There is 32-bit infiniband. Linux kernel assumes that unsigned long is
equivalent to uintptr_t -- in other words all pointers are the same size
as longs. So when casting from integer to pointer we add a cast to
unsigned long to avoid a warning precisely in the 32-bit case -- we
would get a warning about cast to pointer from integer of different size
when casting from 64-bit integer to 32-bit pointer.
--
Roland Dreier <rolandd@xxxxxxxxx> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/