Re: [PATCH] usb: fix warning in usbtest module

From: Greg Dietsche
Date: Sun May 08 2011 - 15:38:12 EST


On 05/08/2011 09:37 AM, Alan Stern wrote:
On Sat, 7 May 2011, Greg Dietsche wrote:

On amd64 unsigned is not as wide as pointer and this causes
a compiler warning. Switching to uintptr_t fixes the problem
in an arch independent manner.
People tend to prefer to see non-typedef'ed type names, whenever
possible. In this case, it would be enough to change the type to
unsigned long.

Lots of code throughout the kernel stores pointer values in unsigned
long variables. I've never heard any recommendation for using
uintptr_t instead.

I was leaning towards unsigned long at first too, but a several things made me reconsider:
1) uintptr_t adapts correctly to the size of a pointer on all architectures per C99
2) I greped the kernel source and found a number of instances where uintptr_t is used
3) unsigned long is technically too wide (though this is better than too small...) for some architectures

If the general consensus is that unsigned long is a better choice for the kernel, I will update my patch. I do, however think that uintptr_t is the best choice from a technical perspective and prefer it over unsigned long.

Thanks,
Greg

--
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/