Hi,
> While this would be a cleaner fix, it also requires extensive changes and
> it is not always easy to decide where to use M_ERRNO and where to use
> M_WINERR. E.g., without looking into the internals of platform.c one
> doesn't know whether platform_open() uses _wopen() or CreateFile().
>
True.
> A possible option is to continue the use of M_ERRNO on WIndows as is
> (except for socket errors), continue to use GetLastError() in x_msg(), but
> if/when the latter if it returns zero, try errno and strerrror(). Not ideal
> but less changes and easier and transparent to the user of msg(). That
> said, I haven't checked whether GetLastError() returns zero or a valid and
> correct error code for C runtime errors -- without which this approach wont
> work.
>
I did some tests, ::GetLastError appears to return zero or correct error
code:
sqrt(-1);
int err = errno; // -33 EDOM
DWORD lasterr = GetLastError(); // 0
_open("c:\\Temp\\notfound", _O_RDONLY);
err = errno; // 2 ENOENT
lasterr = GetLastError(); // 2 ERROR_FILE_NOT_FOUND
_open("c:\\Temp\\directory", _O_RDONLY);
err = errno; // 13 EACCES
lasterr = GetLastError(); // 5 ERROR_ACCESS_DENIED
malloc(10000000000);
err = errno; // 12 ENOMEM
lasterr = GetLastError(); // 8 ERROR_NOT_ENOUGH_MEMORY
So let's go with this approach.
> BTW, there are a couple of uses of strerror() in check_status() (error.c)
> missed by the original patch.
>
Thanks, I will address it in this "proper" fix.
--
-Lev
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel