[PATCH] Fix cast int-to-pointer and pointer-to-int
joerg at britannica.bec.de
Thu Feb 5 09:53:48 PST 2009
On Thu, Feb 05, 2009 at 06:25:40PM +0100, Tomas Carnecky wrote:
> On 02/04/2009 09:04 PM, Joerg Sonnenberger wrote:
>> On Wed, Feb 04, 2009 at 08:43:43PM +0100, Tomas Carnecky wrote:
>>> By first casting to long and then to the final type. Of course
>>> this assumes that sizeof(long) == sizeof(void *). If the Win32
>>> folks care enough about warnings, we could make macros for this.
>> Please use either uintptr_t (prefered) or size_t (fallback) instead of
>> long. Also really make this a macro so that it can easily be searched
> uintptr_t doesn't guarantee what we need either. It only guarantees
> void* -> intptr_t -> void* conversion, but we also need 'intptr_t ->
> void* -> intptr_t'. The man page (stdint.h) doesn't say that intptr_t
> has to be the same width as pointers. It could be 128bits and gcc would
> still throw a warning.
> But if that's considered a non-issue, I'll change the code.
Frankly, that's a problem to worry about when it comes up and that
sounds strongly like a fictional problem. In any case, as long as the
value came originally from a pointer (and why would it be valid
otherwise?), it doesn't matter.
More information about the xorg