Hi On Mon, Feb 21, 2022 at 4:24 AM Lev Stipakov <lstipa...@gmail.com> wrote:
> We had a long discussion with ordex about this patch and came to the > conclusion that error printing is currently broken on Windows and > needs a proper fixing. > > +1 > What we propose: > > - M_ERRNO prints only C runtime errors on all platforms and should be > only used with C runtime functions > - We add M_WINERR which uses GetLastError and FormatMessage to print > Windows errors > 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(). 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. - We add M_SOCKERR, which is resolved into M_ERRNO on all platforms > except Windows and on Windows it is M_WSAERR. We use WSAGetLastError > and FormatMessage to print WSA errors. Socket functions use M_SOCKERR. > Sounds good. BTW, there are a couple of uses of strerror() in check_status() (error.c) missed by the original patch. Selva
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel