On Tue, Oct 13, 2010 at 16:30 PM, Erich Hoover <ehoover(a)mines.edu> wrote:
... + int newsize = (int)*maxsize; + + /* Make sure there is at least enough room for this entry */ + newsize -= sizeof(WSACMSGHDR) + CMSG_ALIGN(len); + if (newsize < 0) + return 0; + *maxsize = (ULONG)newsize; Just declare it as a ULONG/size_t so you don't have to cast.
I can obviously change this around a little bit, but the reason for this conversion is that as a >ULONG the "if (newsize < 0)" comparison is not going to work.
Then following code would work better: ULONG newsize = sizeof(WSACMSGHDR) + CMSG_ALIGN(len); /* Make sure there is at least enough room for this entry */ if (newsize > *maxsize) return 0; /* else */ *maxsize -= newsize; Rolf Kalbermatter