[Libguestfs] [nbdkit] Windows errno handling

Richard W.M. Jones rjones at redhat.com
Mon Aug 17 21:48:16 UTC 2020


On Mon, Aug 17, 2020 at 07:36:00PM +0100, Richard W.M. Jones wrote:
> We'd have to then need to wrap all assignments to errno
> in a macro like:
> 
>  #ifndef WIN32
>  #define set_errno(v) (errno = (v))
>  #else
>  #define set_errno(v) (WSASetLastError (translate_from_errno (v)))
>  #endif
>
> This is very invasive for existing code.  There are ~60 places in the
> existing code which seem to assign to errno, ...

I think we _don't_ need to do this.  That's because we never actually
want to call WSASetLastError for a couple of reasons: (a) Just like
for Linux, no Windows API call would be affected by WSASetLastError.
(b) errno is a thread safe global variable on Windows which can also
be assigned
(https://stackoverflow.com/questions/6413052/msvc-errno-thread-safety).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list