Message32781
This patch is one of a set of five (one per python/dist/src/* directory).
They have been broken up to keep the patches small such that people might
spend the time to review them. If one single patch would be prefered I can
provide that.
This patch makes some simple changes for the benefit of 64-bit platforms (to
avoid possible overflows where C data types have changed sizes and to
eliminate unnecessary warnings). Each change fits into one of the following
categories:
- Change a local variable declaration from int to size_t where appropriate.
This is typically done for variables that hold strlen() or sizeof()
results. On 64-bit platforms sizeof(int) < sizeof(size_t), so using size_t
avoids a downcast warning (or overflow). The variable is often later
downcast to an int anyway but it is (IMO) more appropriate to do the
downcast where the downcast is necessary and not before. 32-bit platforms
are not affected by this change.
- Change (int) casts to (size_t) casts within comparisons where appropriate.
This can avoid an unnecessary possible overflow (in somecases) and a
warning on 64-bit platforms.
- Remove pointer downcasts to (long) for comparison (see Objects/object.c).
This is unreliable on Win64 where sizeof(void*) > sizeof(long).
- Add a check for int overflow and raise and OverflowError where it cannot be
proven a priori that int will not overflow. This is usually associated with
string lengths. While it may seem overkill to have a check to ensure that a
string does not overflow 2G characters it *is* a potential for silent
overflow.
- [Python/thread_nt.c] Use %p instead of %ld printf formatter for debugging
output to print a pointer. %ld results in data loss on Win64.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:59:33 | admin | link | issue400523 messages |
2007-08-23 14:59:33 | admin | create | |
|