On 30.8.2007, at 15.49, Bérczi Gábor (Gabucino) wrote:

For example in src/lib/file-cache.c:

if (cache->mmap_base == MAP_FAILED) {

Should be fixed, probably like this:

if ((int)cache->mmap_base == MAP_FAILED) {

No. MAP_FAILED is supposed to be a pointer. For example in Linux:

/usr/include/sys/mman.h:#define MAP_FAILED      ((void *) -1)

And in any case you really don't want to cast it to int, rather ssize_t so that it won't break with 64bit systems.

And indeed, unsigned integers and -1 are rarely equal.

Not really, Dovecot does such comparisons a lot. :)

Casting an unsigned integer to signed where the original value doesn't fit to the destination is undefined by ANSI C. Casting a signed integer to unsigned integer however is valid. (unsigned int)-1 means the largest value that the unsigned int can hold. So comparing unsigned int to -1 means comparing it to the largest value.

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to