[PATCH] properly check error return from socket() and accept() calls

Ozkan Sezer sezeroz@gmail.com
Fri Apr 2 08:46:00 GMT 2010


Hi:

socket() and accept() calls do not return "some negative value" on error,
they specifically return "-1". Therefore, the error return checks from
those calls must be done by checking equality to -1 not by being negative.
This is important for Win32 where the SOCKET type is actually unsigned
and the operating system has every right to return a value > INT_MAX and
< UINT_MAX and since gdb is using a signed int type for socket fd (which
is broken for Win64 where SOCKET type is uintptr_t, but that's for another
time), the negativity check may evaluate to true even if the socket() or
accept() call actually succeeded. The attached trivial patch fixes this as
described. For uniformity's sake, I also touched the files under sim/.
Please consider for applying. (The patch file has the ChangeLog. I don't
have write access.)

--
Ozkan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: socket_err_checks.patch
Type: application/octet-stream
Size: 7105 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20100402/739d067a/attachment.obj>


More information about the Gdb-patches mailing list