rpms/centericq/devel centericq-src.patch, NONE, 1.1 centericq.spec, 1.14, 1.15
Ralf Corsepius
rc040203 at freenet.de
Mon May 30 07:51:31 UTC 2005
Andreas,
On Sun, 2005-05-29 at 16:49 -0400, Andreas Bierfert wrote:
> Author: awjb
>
> Update of /cvs/extras/rpms/centericq/devel
> In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31285
> - if(i) f = (unsigned short) ((int) m.getref(i-1));
> + if(i) f = (unsigned short) ((size_t) m.getref(i-1));
> +- and again more size_t fixes in src
I noticed you adding more and more size_t casts in places, where 32bit
code cast pointers to int.
I guess you are aware, that size_t is not an appropriate type for such
purposes.
size_t is defined as (from IEEE Std 1003.1, 2004 Edition 6, aka SUSV):
> size_t
> Unsigned integer type of the result of the sizeof operator.
I.e. it is not by any means connected to casting pointers to int and is
_not_ guaranteed to be large enough to take a pointer.
The fact it works for on linux is a random accident being caused by
sizeof(void*) == sizeof(size_t) == sizeof(long)
on linux target and most other modern OSes.
In C99 code, uintptr_t and intptr_t are the types designated for casting
pointers to "int":
>From SUSV (stdint.h):
> Integer types capable of holding object pointers
>
> The following type designates a signed integer type with the property
> that any valid pointer to void can be converted to this type, then
> converted back to a pointer to void, and the result will compare equal
> to the original pointer: intptr_t
>
> The following type designates an unsigned integer type with the
> property that any valid pointer to void can be converted to this type,
> then converted back to a pointer to void, and the result will compare
> equal to the original pointer: uintptr_t
>
> [XSI] [Option Start]On XSI-conformant systems, the intptr_t and
> uintptr_t types are required; [Option End] otherwise, they are
> optional.
For code predating c99/XSI, the best estimate to intptr_t and uintptr_t
is directly using "long" rsp. "unsigned long".
size_t in many cases is not correct.
Ralf
More information about the fedora-extras-commits
mailing list