Re: Re: [PATCH] exif warning fix?
| From: | Joe Orton | Date: | Thu, 10 Mar 2005 10:43:55 +0000 |
| Subject: | Re: Re: [PATCH] exif warning fix? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-15342@lists.php.net to get a copy of this message | ||
On Thu, Mar 10, 2005 at 11:23:51AM +0100, Ard Biesheuvel wrote:
> Joe Orton wrote:
> >Testing "length >= LONG_MAX" where length is an int is always false, and
> >gcc gives a warning for it. Perhaps something like this was intended?
> >
>
> On 64-bit it is always false, however on 32-bit 'length == LONG_MAX' can
> be true. That's probably why noone caught the warning so far, as gcc
> would not emit it on a 32-bit system.
>
> If you're testing for overflow, casting to unsigned int won't help you
> here, as the overflow will already have occurred when length was
> assigned its value.
Yes, sorry, I haven't turned my brain on yet this morning. So perhaps a
test for (length < 0) is all that's really needed; I can't see why
length == INT_MAX is particularly a special case here...
joe