From: Frank Lichtenheld Date: Tue, 7 Feb 2023 13:43:33 +0000 (+0100) Subject: Windows: fix wrong printf format in x_check_status X-Git-Tag: v2.7_alpha1~564 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a95705be85cb1d3a5868efaeb960ec5d625d2f11;p=thirdparty%2Fopenvpn.git Windows: fix wrong printf format in x_check_status Relevant defines/typedefs: typedef UINT_PTR SOCKET; if defined(_WIN64) typedef unsigned __int64 UINT_PTR; else typedef unsigned int UINT_PTR; endif ifdef _WIN64 define PRIuPTR PRIu64 else define PRIuPTR PRIu32 endif Remove duplicated include of inttypes.h Signed-off-by: Frank Lichtenheld Acked-by: Lev Stipakov Message-Id: <20230207134333.52221-1-frank@lichtenheld.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26166.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 89a08cecd..a2c9aa4c9 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -695,14 +695,14 @@ x_check_status(int status, { if (extended_msg) { - msg(x_cs_info_level, "%s %s [%s]: %s (fd=%d,code=%d)", description, + msg(x_cs_info_level, "%s %s [%s]: %s (fd=" SOCKET_PRINTF ",code=%d)", description, sock ? proto2ascii(sock->info.proto, sock->info.af, true) : "", extended_msg, openvpn_strerror(my_errno, crt_error, &gc), sock ? sock->sd : -1, my_errno); } else { - msg(x_cs_info_level, "%s %s: %s (fd=%d,code=%d)", description, + msg(x_cs_info_level, "%s %s: %s (fd=" SOCKET_PRINTF ",code=%d)", description, sock ? proto2ascii(sock->info.proto, sock->info.af, true) : "", openvpn_strerror(my_errno, crt_error, &gc), sock ? sock->sd : -1, my_errno); diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index fe91bc113..12ccf2f4d 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -48,7 +48,6 @@ #ifdef _MSC_VER /* Visual Studio */ #define __func__ __FUNCTION__ #define __attribute__(x) -#include #endif #if defined(__APPLE__) @@ -442,9 +441,11 @@ typedef unsigned short sa_family_t; */ #ifdef _WIN32 #define SOCKET_UNDEFINED (INVALID_SOCKET) +#define SOCKET_PRINTF "%" PRIuPTR typedef SOCKET socket_descriptor_t; #else #define SOCKET_UNDEFINED (-1) +#define SOCKET_PRINTF "%d" typedef int socket_descriptor_t; #endif