Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Message

Re: [milter-greylist] race condition ?

2005-04-08 by Matt Kettler

Emmanuel Dreyfus wrote:

>That means that in pending.c:pending_check(), we don't match the
>if (rest < 0) condition.
>
>rest is time_t. that is signed on my system, is it on yours?
>Try running this:
>
>int main(void) {
>	size_t x = -1;;
>
>	printf("x = %d\n", x);
>	return 0;
>}
>
>  
>
Emmanuel.. Are you sure that's going to tell you anything useful?

The difference between signed and unsigned is in how the values are
interpreted. You can take -1, cast it as unsigned, and back to signed
and still wind up with -1.

Since %d tells printf to interpret the value as signed int, it should
print -1, even if size_t is unsigned.

$ cat test.c
int main (void)
{
    unsigned x = -1;
    printf ("x = %d",x);
    return 0;
}
$ gcc test.c
$ ./a.out
x = -1

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.