On Tue, Apr 8, 2014 at 11:32 PM, Bruce Momjian <br...@momjian.us> wrote:
> On Sun, Apr  6, 2014 at 11:45:59AM +0530, Amit Kapila wrote:
> In fact, this C program compiled by gcc on Debian issues no compiler
> warnings and returns 'hello', showing that -1 and ~0 compare as equal:
>
>         int
>         main(int argc, char **argv)
>         {
>             int i;
>             unsigned int j;
>
>             i = -1;
>             j = ~0;
>
>             if (i == j)
>                 printf("hello\n");
>
>             return 0;
>         }

I have add below code to check it's usage as per PG:

if (j < 0)
printf("hello-1\n");

It doesn't print hello-1, which means that all the check's in code
for <sock_desc> < 0 can have problem.

>> 1.
>> int
>> pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
>> sock = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);
>> if (sock == SOCKET_ERROR)
>
> Well, the actual problem here is that WSASocket() returns INVALID_SOCKET
> per the documentation, not SOCKET_ERROR.  I did not use PGINVALID_SOCKET
> here because this is Windows-specific code, defining 'sock' as SOCKET.
> We could have sock defined as pgsocket, but because this is Windows code
> already, it doesn't seem wise to mix portability code in there.

I think it's better to use check like below, just for matter of
consistency with other place
if (sock == INVALID_SOCKET)

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to