(size_t) and (unsigned)

Gerrit Pape <[email protected]> Wed, 6 Dec 2006 16:50:30 +0000
Newsgroups gmane.comp.sysutils.bgware
Message-ID <[email protected]>
Hi, at several places in bglibs and cvm there's a comparision between
(size_t) and (unsigned)-1, e.g. cvm-0.76:

module_command.c:  size_t wr;
module_command.c:    if ((wr = write(1, ptr, cvm_module_outbuflen)) == (unsigned)-1

It looks like this doesn't work as expected on 64bit platforms, at least
amd64 and ia64, where size_t is long unsigned int:

 $ uname -m
 x86_64
 $ cat ttt.c
 #include <sys/types.h>
 $ gcc -E ttt.c |grep size_t |head -n1
 typedef long unsigned int size_t;
 $ 

 $ uname -m
 ia64
 $ cat ttt.c 
 #include <sys/types.h>
 $ gcc -E ttt.c |grep size_t |head -n1
 typedef long unsigned int size_t;
 $ 

 $ uname -m
 i686
 $ cat ttt.c 
 #include <sys/types.h>
 $ gcc -E ttt.c |grep size_t |head -n1
 typedef unsigned int size_t;
 $ 

Regards, Gerrit.