Currently any socket functions that are replaced by Gnulib on Win32 call set_winsock_errno. This function reads the error from winsock (WSAGetLastError) and sets errno to some corresponding Unix-ish approximation. The vast majority of functions (non-socket ones) still require you to deal with GetLastError and Windows error codes.
Unfortunately set_winsock_errno also does this: static inline void set_winsock_errno (void) { int err = WSAGetLastError (); WSASetLastError (0); <----- which means that no one else ever gets to read the underlying Windows error code. It also complicates error handling unnecessarily (even more so than it is already on Windows). Is there a reason to have that line or can it just be removed? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
>From 8f5a44c506468bf50a79b64be9e38854930d7b5e Mon Sep 17 00:00:00 2001 From: Richard Jones <rjo...@redhat.com> Date: Thu, 26 Nov 2009 16:51:19 +0000 Subject: [PATCH] set_winsock_errno: Don't hide the original Windows error code. --- lib/w32sock.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/lib/w32sock.h b/lib/w32sock.h index 0622985..8705f8f 100644 --- a/lib/w32sock.h +++ b/lib/w32sock.h @@ -32,7 +32,6 @@ static inline void set_winsock_errno (void) { int err = WSAGetLastError (); - WSASetLastError (0); /* Map some WSAE* errors to the runtime library's error codes. */ switch (err) -- 1.6.5.2