From: "flichtenheld (Code Review)" Date: Mon, 15 Sep 2025 14:14:59 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <71eecd7e21c55461cf7fb07e89e4542e8746ed7d-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="weuBPlnz8+M="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Change msglevel flags to int List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --weuBPlnz8+M= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1189?usp=3Demail to review the following change. Change subject: Change msglevel flags to int ...................................................................... Change msglevel flags to int The API said they are unsigned, but most callers actually used int. So this produced a LOT of warnings when enabling -Wsign-conversion. Since changing the API is actually a smaller change than changing all the callers, we do that. Change-Id: I4b0078d099e975d223825194ad104945b1247554 Signed-off-by: Frank Lichtenheld --- M src/openvpn/crypto_mbedtls.c M src/openvpn/crypto_mbedtls.h M src/openvpn/crypto_openssl.c M src/openvpn/crypto_openssl.h M src/openvpn/error.c M src/openvpn/error.h M src/openvpn/manage.c M src/openvpn/manage.h M src/openvpn/options.c M src/openvpn/options.h M src/openvpn/pkcs11.c M src/openvpn/platform.c M src/openvpn/plugin.c M src/openvpn/proto.c M src/openvpn/status.h M src/openvpnmsica/dllmain.c M src/tapctl/error.c M src/tapctl/error.h M src/tapctl/main.c M tests/unit_tests/openvpn/mock_msg.c M tests/unit_tests/openvpn/test_cryptoapi.c M tests/unit_tests/openvpn/test_pkcs11.c 22 files changed, 71 insertions(+), 72 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/1189/1 diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index 0c15812..3c2b66f 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -105,7 +105,7 @@ } bool -mbed_log_err(unsigned int flags, int errval, const char *prefix) +mbed_log_err(int flags, int errval, const char *prefix) { if (0 !=3D errval) { @@ -123,7 +123,7 @@ } bool -mbed_log_func_line(unsigned int flags, int errval, const char *func, int l= ine) +mbed_log_func_line(int flags, int errval, const char *func, int line) { char prefix[256]; diff --git a/src/openvpn/crypto_mbedtls.h b/src/openvpn/crypto_mbedtls.h index 80f1d16..c9d4fe6 100644 --- a/src/openvpn/crypto_mbedtls.h +++ b/src/openvpn/crypto_mbedtls.h @@ -106,7 +106,7 @@ * * @returns true if no errors are detected, false otherwise. */ -bool mbed_log_err(unsigned int flags, int errval, const char *prefix); +bool mbed_log_err(int flags, int errval, const char *prefix); /** * Log the supplied mbed TLS error, prefixed by function name and line num= ber. @@ -118,11 +118,11 @@ * * @returns true if no errors are detected, false otherwise. */ -bool mbed_log_func_line(unsigned int flags, int errval, const char *func, = int line); +bool mbed_log_func_line(int flags, int errval, const char *func, int line); /** Wraps mbed_log_func_line() to prevent function calls for non-errors */ static inline bool -mbed_log_func_line_lite(unsigned int flags, int errval, const char *func, = int line) +mbed_log_func_line_lite(int flags, int errval, const char *func, int line) { if (errval) { diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 19ca88c..bacc89f 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -227,7 +227,7 @@ } void -crypto_print_openssl_errors(const unsigned int flags) +crypto_print_openssl_errors(const int flags) { unsigned long err =3D 0; int line, errflags; diff --git a/src/openvpn/crypto_openssl.h b/src/openvpn/crypto_openssl.h index 6218b39..21dae4f 100644 --- a/src/openvpn/crypto_openssl.h +++ b/src/openvpn/crypto_openssl.h @@ -103,7 +103,7 @@ * * @param flags Flags to indicate error type and priority. */ -void crypto_print_openssl_errors(const unsigned int flags); +void crypto_print_openssl_errors(const int flags); /** * Retrieve any OpenSSL errors, then print the supplied error message. diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 1b98235..8043afe 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -48,7 +48,7 @@ #endif /* Globals */ -unsigned int x_debug_level; /* GLOBAL */ +int x_debug_level; /* GLOBAL */ /* Mute state */ static int mute_cutoff; /* GLOBAL */ @@ -101,7 +101,7 @@ } bool -set_debug_level(const int level, const unsigned int flags) +set_debug_level(const int level, const int flags) { const int ceiling =3D 15; @@ -190,7 +190,7 @@ * Return a file to print messages to before syslog is opened. */ FILE * -msg_fp(const unsigned int flags) +msg_fp(const int flags) { FILE *fp =3D msgfp; if (!fp) @@ -214,7 +214,7 @@ int x_msg_line_num; /* GLOBAL */ void -x_msg(const unsigned int flags, const char *format, ...) +x_msg(const int flags, const char *format, ...) { va_list arglist; va_start(arglist, format); @@ -235,7 +235,7 @@ } void -x_msg_va(const unsigned int flags, const char *format, va_list arglist) +x_msg_va(const int flags, const char *format, va_list arglist) { struct gc_arena gc; #if SYSLOG_CAPABILITY @@ -385,7 +385,7 @@ * Apply muting filter. */ bool -dont_mute(unsigned int flags) +dont_mute(int flags) { bool ret =3D true; if (mute_cutoff > 0 && !(flags & M_NOMUTE)) @@ -599,9 +599,9 @@ * of I/O operations. */ -unsigned int x_cs_info_level; /* GLOBAL */ -unsigned int x_cs_verbose_level; /* GLOBAL */ -unsigned int x_cs_err_delay_ms; /* GLOBAL */ +int x_cs_info_level; /* GLOBAL */ +int x_cs_verbose_level; /* GLOBAL */ +unsigned int x_cs_err_delay_ms; /* GLOBAL */ void reset_check_status(void) @@ -611,7 +611,7 @@ } void -set_check_status(unsigned int info_level, unsigned int verbose_level) +set_check_status(int info_level, int verbose_level) { x_cs_info_level =3D info_level; x_cs_verbose_level =3D verbose_level; @@ -750,7 +750,7 @@ * Translate msg flags into a string */ const char * -msg_flags_string(const unsigned int flags, struct gc_arena *gc) +msg_flags_string(const int flags, struct gc_arena *gc) { struct buffer out =3D alloc_buf_gc(16, gc); if (flags =3D=3D M_INFO) diff --git a/src/openvpn/error.h b/src/openvpn/error.h index 8388f82..babb42f 100644 --- a/src/openvpn/error.h +++ b/src/openvpn/error.h @@ -78,7 +78,7 @@ * These globals should not be accessed directly, * but rather through macros or inline functions defined below. */ -extern unsigned int x_debug_level; +extern int x_debug_level; extern int x_msg_line_num; /* msg() flags */ @@ -135,7 +135,7 @@ */ /** Check muting filter */ -bool dont_mute(unsigned int flags); +bool dont_mute(int flags); /* Macro to ensure (and teach static analysis tools) we exit on fatal erro= rs */ #define EXIT_FATAL(flags) \ @@ -170,7 +170,7 @@ #define dmsg(flags, ...) #endif -void x_msg(const unsigned int flags, const char *format, ...) +void x_msg(const int flags, const char *format, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO __attribute__((format(gnu_printf, 2, 3))) @@ -180,7 +180,7 @@ #endif ; /* should be called via msg above */ -void x_msg_va(const unsigned int flags, const char *format, va_list arglis= t); +void x_msg_va(const int flags, const char *format, va_list arglist); /* * Function prototypes @@ -197,7 +197,7 @@ #define SDL_CONSTRAIN (1 << 0) -bool set_debug_level(const int level, const unsigned int flags); +bool set_debug_level(const int level, const int flags); bool set_mute_cutoff(const int cutoff); @@ -205,12 +205,12 @@ int get_mute_cutoff(void); -const char *msg_flags_string(const unsigned int flags, struct gc_arena *gc= ); +const char *msg_flags_string(const int flags, struct gc_arena *gc); /* * File to print messages to before syslog is opened. */ -FILE *msg_fp(const unsigned int flags); +FILE *msg_fp(const int flags); /* Fatal logic errors */ #ifndef ENABLE_SMALL @@ -254,14 +254,14 @@ /* Inline functions */ static inline bool -check_debug_level(unsigned int level) +check_debug_level(int level) { return (level & M_DEBUG_LEVEL) <=3D x_debug_level; } /** Return true if flags represent an enabled, not muted log level */ static inline bool -msg_test(unsigned int flags) +msg_test(int flags) { return check_debug_level(flags) && dont_mute(flags); } @@ -297,13 +297,13 @@ struct link_socket; struct tuntap; -extern unsigned int x_cs_info_level; -extern unsigned int x_cs_verbose_level; +extern int x_cs_info_level; +extern int x_cs_verbose_level; extern unsigned int x_cs_err_delay_ms; void reset_check_status(void); -void set_check_status(unsigned int info_level, unsigned int verbose_level); +void set_check_status(int info_level, int verbose_level); void x_check_status(int status, const char *description, struct link_socke= t *sock, struct tuntap *tt); @@ -400,8 +400,8 @@ } /** Convert fatal errors to nonfatal, don't touch other errors */ -static inline unsigned int -nonfatal(const unsigned int err) +static inline int +nonfatal(const int err) { return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err; } @@ -409,21 +409,20 @@ static inline int openvpn_errno_maybe_crt(bool *crt_error) { - int err =3D 0; *crt_error =3D false; #ifdef _WIN32 - err =3D GetLastError(); + int err =3D (int)GetLastError(); if (err =3D=3D ERROR_SUCCESS) { /* error is likely C runtime */ *crt_error =3D true; err =3D errno; } + return err; #else /* ifdef _WIN32 */ *crt_error =3D true; - err =3D errno; + return errno; #endif - return err; } #include "errlevel.h" diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 4f37bd2..87981d2 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -352,7 +352,7 @@ } static void -virtual_output_callback_func(void *arg, const unsigned int flags, const ch= ar *str) +virtual_output_callback_func(void *arg, const int flags, const char *str) { struct management *man =3D (struct management *)arg; static int recursive_level =3D 0; /* GLOBAL */ diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 7c189ba..7196210 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -98,7 +98,7 @@ union log_entry_union { - unsigned int msg_flags; + int msg_flags; int state; int intval; }; diff --git a/src/openvpn/options.c b/src/openvpn/options.c index e47d54c..22b36a3 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -4869,7 +4869,7 @@ #ifdef _WIN32 void -show_windows_version(const unsigned int flags) +show_windows_version(const int flags) { struct gc_arena gc =3D gc_new(); msg(flags, "Windows version: %s", win32_version_string(&gc)); @@ -4878,7 +4878,7 @@ #endif void -show_dco_version(const unsigned int flags) +show_dco_version(const int flags) { #ifdef ENABLE_DCO struct gc_arena gc =3D gc_new(); @@ -4888,7 +4888,7 @@ } void -show_library_versions(const unsigned int flags) +show_library_versions(const int flags) { #ifdef ENABLE_LZO #define LZO_LIB_VER_STR ", LZO ", lzo_version_string() diff --git a/src/openvpn/options.h b/src/openvpn/options.h index bb2c052..b8efdf8 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -830,14 +830,14 @@ void usage_small(void); -void show_library_versions(const unsigned int flags); +void show_library_versions(const int flags); #ifdef _WIN32 -void show_windows_version(const unsigned int flags); +void show_windows_version(const int flags); #endif -void show_dco_version(const unsigned int flags); +void show_dco_version(const int flags); void init_options(struct options *o, const bool init_gc); diff --git a/src/openvpn/pkcs11.c b/src/openvpn/pkcs11.c index d9c16d9..ba81c54 100644 --- a/src/openvpn/pkcs11.c +++ b/src/openvpn/pkcs11.c @@ -77,10 +77,10 @@ #endif }; -static unsigned -_pkcs11_msg_pkcs112openvpn(const unsigned flags) +static int +_pkcs11_msg_pkcs112openvpn(const unsigned int flags) { - unsigned openvpn_flags; + int openvpn_flags; switch (flags) { @@ -117,7 +117,7 @@ } static unsigned -_pkcs11_msg_openvpn2pkcs11(const unsigned flags) +_pkcs11_msg_openvpn2pkcs11(const int flags) { unsigned pkcs11_flags; diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index 880d14e..78c56d3 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -223,7 +223,7 @@ const struct platform_state_group *group_state, st= ruct context *c) { int keep_caps =3D need_keep_caps(c); - unsigned int err_flags =3D (keep_caps > 0) ? M_FATAL : M_NONFATAL; + int err_flags =3D (keep_caps > 0) ? M_FATAL : M_NONFATAL; #ifdef HAVE_LIBCAPNG int new_gid =3D -1, new_uid =3D -1; int res; diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c index ea76a08..b14ce5c 100644 --- a/src/openvpn/plugin.c +++ b/src/openvpn/plugin.c @@ -371,7 +371,7 @@ static void plugin_vlog(openvpn_plugin_log_flags_t flags, const char *name, const char= *format, va_list arglist) { - unsigned int msg_flags =3D 0; + int msg_flags =3D 0; if (!format) { diff --git a/src/openvpn/proto.c b/src/openvpn/proto.c index 34b3378..b0373df 100644 --- a/src/openvpn/proto.c +++ b/src/openvpn/proto.c @@ -183,7 +183,7 @@ int hlen; int totlen; const char *msgstr =3D "PACKET SIZE INFO"; - unsigned int msglevel =3D D_PACKET_TRUNC_DEBUG; + int msglevel =3D D_PACKET_TRUNC_DEBUG; if (BLEN(&buf) < (int)sizeof(struct openvpn_iphdr)) { diff --git a/src/openvpn/status.h b/src/openvpn/status.h index 0c7a869..c318683 100644 --- a/src/openvpn/status.h +++ b/src/openvpn/status.h @@ -32,11 +32,11 @@ { void *arg; unsigned int flags_default; - void (*func)(void *arg, const unsigned int flags, const char *str); + void (*func)(void *arg, const int flags, const char *str); }; static inline void -virtual_output_print(const struct virtual_output *vo, const unsigned int f= lags, const char *str) +virtual_output_print(const struct virtual_output *vo, const int flags, con= st char *str) { (*vo->func)(vo->arg, flags, str); } diff --git a/src/openvpnmsica/dllmain.c b/src/openvpnmsica/dllmain.c index e7d4a4b..8b1b7e9 100644 --- a/src/openvpnmsica/dllmain.c +++ b/src/openvpnmsica/dllmain.c @@ -91,7 +91,7 @@ bool -dont_mute(unsigned int flags) +dont_mute(int flags) { UNREFERENCED_PARAMETER(flags); @@ -100,7 +100,7 @@ void -x_msg_va(const unsigned int flags, const char *format, va_list arglist) +x_msg_va(const int flags, const char *format, va_list arglist) { /* Secure last error before it is overridden. */ DWORD dwResult =3D (flags & M_ERRNO) !=3D 0 ? GetLastError() : ERROR_S= UCCESS; diff --git a/src/tapctl/error.c b/src/tapctl/error.c index 9f5094e..27a475a 100644 --- a/src/tapctl/error.c +++ b/src/tapctl/error.c @@ -22,11 +22,11 @@ /* Globals */ -unsigned int x_debug_level; /* GLOBAL */ +int x_debug_level; /* GLOBAL */ void -x_msg(const unsigned int flags, const char *format, ...) +x_msg(const int flags, const char *format, ...) { va_list arglist; va_start(arglist, format); diff --git a/src/tapctl/error.h b/src/tapctl/error.h index fb24a61..ee9909a 100644 --- a/src/tapctl/error.h +++ b/src/tapctl/error.h @@ -29,7 +29,7 @@ * These globals should not be accessed directly, * but rather through macros or inline functions defined below. */ -extern unsigned int x_debug_level; +extern int x_debug_level; extern int x_msg_line_num; /* msg() flags */ @@ -58,7 +58,7 @@ /** Check muting filter */ -bool dont_mute(unsigned int flags); +bool dont_mute(int flags); /* Macro to ensure (and teach static analysis tools) we exit on fatal erro= rs */ #ifdef _MSC_VER @@ -97,21 +97,21 @@ #define dmsg(flags, ...) #endif -void x_msg(const unsigned int flags, const char *format, ...); /* should b= e called via msg above */ +void x_msg(const int flags, const char *format, ...); /* should be called = via msg above */ -void x_msg_va(const unsigned int flags, const char *format, va_list arglis= t); +void x_msg_va(const int flags, const char *format, va_list arglist); =20 /* Inline functions */ static inline bool -check_debug_level(unsigned int level) +check_debug_level(int level) { return (level & M_DEBUG_LEVEL) <=3D x_debug_level; } /** Return true if flags represent and enabled, not muted log level */ static inline bool -msg_test(unsigned int flags) +msg_test(int flags) { return check_debug_level(flags) && dont_mute(flags); } diff --git a/src/tapctl/main.c b/src/tapctl/main.c index 031e262..52cc8e22 100644 --- a/src/tapctl/main.c +++ b/src/tapctl/main.c @@ -479,7 +479,7 @@ bool -dont_mute(unsigned int flags) +dont_mute(int flags) { UNREFERENCED_PARAMETER(flags); @@ -488,7 +488,7 @@ =20 void -x_msg_va(const unsigned int flags, const char *format, va_list arglist) +x_msg_va(const int flags, const char *format, va_list arglist) { /* Output message string. Note: Message strings don't contain line ter= minators. */ vfprintf(stderr, format, arglist); diff --git a/tests/unit_tests/openvpn/mock_msg.c b/tests/unit_tests/openvpn= /mock_msg.c index 603520b..a2d9c72 100644 --- a/tests/unit_tests/openvpn/mock_msg.c +++ b/tests/unit_tests/openvpn/mock_msg.c @@ -38,8 +38,8 @@ #include "error.h" #include "mock_msg.h" -unsigned int x_debug_level =3D 0; /* Default to (almost) no debugging outp= ut */ -unsigned int print_x_debug_level =3D 0; +int x_debug_level =3D 0; /* Default to (almost) no debugging output */ +int print_x_debug_level =3D 0; bool fatal_error_triggered =3D false; @@ -71,7 +71,7 @@ } void -x_msg_va(const unsigned int flags, const char *format, va_list arglist) +x_msg_va(const int flags, const char *format, va_list arglist) { if (flags & M_FATAL) { @@ -89,7 +89,7 @@ } void -x_msg(const unsigned int flags, const char *format, ...) +x_msg(const int flags, const char *format, ...) { va_list arglist; va_start(arglist, format); @@ -128,7 +128,7 @@ } bool -dont_mute(unsigned int flags) +dont_mute(int flags) { return true; } diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/o= penvpn/test_cryptoapi.c index 6e83465..cff9547 100644 --- a/tests/unit_tests/openvpn/test_cryptoapi.c +++ b/tests/unit_tests/openvpn/test_cryptoapi.c @@ -59,7 +59,7 @@ /* replacement for crypto_print_openssl_errors() */ void -crypto_print_openssl_errors(const unsigned int flags) +crypto_print_openssl_errors(const int flags) { unsigned long e; while ((e =3D ERR_get_error())) diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/open= vpn/test_pkcs11.c index 9ba6cfc..961d78b 100644 --- a/tests/unit_tests/openvpn/test_pkcs11.c +++ b/tests/unit_tests/openvpn/test_pkcs11.c @@ -47,7 +47,7 @@ /* replacement for crypto_print_openssl_errors() */ void -crypto_print_openssl_errors(const unsigned int flags) +crypto_print_openssl_errors(const int flags) { unsigned long e; while ((e =3D ERR_get_error())) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1189?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I4b0078d099e975d223825194ad104945b1247554 Gerrit-Change-Number: 1189 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --weuBPlnz8+M= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

Change msglevel flags to int

The API said they are un= signed, but most callers
actually used int. So this produced a LOT ofwarnings when enabling -Wsign-conversion.

Since changing the API is= actually a smaller change
than changing all the callers, we do that.
Change-Id: I4b0078d099e975d223825194ad104945b1247554
Signed-off-by:= Frank Lichtenheld <frank@...2641...>
---
M src/openvpn/crypto_= mbedtls.c
M src/openvpn/crypto_mbedtls.h
M src/openvpn/crypto_openssl= .c
M src/openvpn/crypto_openssl.h
M src/openvpn/error.c
M src/open= vpn/error.h
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/op= envpn/options.c
M src/openvpn/options.h
M src/openvpn/pkcs11.c
M s= rc/openvpn/platform.c
M src/openvpn/plugin.c
M src/openvpn/proto.cM src/openvpn/status.h
M src/openvpnmsica/dllmain.c
M src/tapctl/err= or.c
M src/tapctl/error.h
M src/tapctl/main.c
M tests/unit_tests/o= penvpn/mock_msg.c
M tests/unit_tests/openvpn/test_cryptoapi.c
M tests= /unit_tests/openvpn/test_pkcs11.c
22 files changed, 71 insertions(+), 72= deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn ref=
s/changes/89/1189/1
diff --git a/src/openvpn/crypto_mbedtls.c b/src=
/openvpn/crypto_mbedtls.c
index 0c15812..3c2b66f 100644
--- a/src/openvpn/crypto_mbedtls.c
+++ b/src/o= penvpn/crypto_mbedtls.c
@@ -105,7 +105,7 @@
}


bool
-mbed_log_err(unsigned int flags, int errval, const ch= ar *prefix)
+mbed_log= _err(int flags, int errval, const char *prefix)
{ if (0 !=3D errval)
{
@@ -= 123,7 +123,7 @@
}

bool<= /span>
-mbed_log_func_line(uns= igned int flags, int errval, const char *func, int line)
+mbed_log_func_line(int flags, int errv= al, const char *func, int line)
{
cha= r prefix[256];

diff --git a/src/openvpn/c= rypto_mbedtls.h b/src/openvpn/crypto_mbedtls.h
index 80f1d1= 6..c9d4fe6 100644
--- a/src/openvpn/crypto_mbedtls.h=
+++ b/src/openvpn/crypto_mbedtls.h
@@ -106,7 +106= ,7 @@
*
* @returns true if no errors ar= e detected, false otherwise.
*/
-bool mbed_log_err(unsigned int flags, int errva= l, const char *prefix);
+bool mbed_log_err(int flags, int errval, const char *prefix);
/**
* Log the supplied mbed TLS= error, prefixed by function name and line number.
@@ -118,= 11 +118,11 @@
*
* @returns true if no e= rrors are detected, false otherwise.
*/
-bool mbed_log_func_line(unsigned int fl= ags, int errval, const char *func, int line);
+bool mbed_log_func_line(int flags, int errval, co= nst char *func, int line);

/** Wraps mbe= d_log_func_line() to prevent function calls for non-errors */
static inline bool

= -mbed_log_func_line_lite(unsigned int flags, int errval, const char *func, = int line)
+mbed_log_f= unc_line_lite(int flags, int errval, const char *func, int line)
= {
if (errval)
{
= diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openss= l.c
index 19ca88c..bacc89f 100644
--- a/src= /openvpn/crypto_openssl.c
+++ b/src/openvpn/crypto_openssl.= c
@@ -227,7 +227,7 @@
}
<= /span>
void
-= crypto_print_openssl_errors(const unsigned int flags)
+crypto_print_openssl_errors(const int fla= gs)
{
unsigned long err =3D 0;=
int line, errflags;
diff --git a/src/openvpn= /crypto_openssl.h b/src/openvpn/crypto_openssl.h
index 6218= b39..21dae4f 100644
--- a/src/openvpn/crypto_openssl.h
+++ b/src/openvpn/crypto_openssl.h
@@ -103,7 +1= 03,7 @@
*
* @param flags Flags = to indicate error type and priority.
*/
-void crypto_print_openssl_errors(const = unsigned int flags);
= +void crypto_print_openssl_errors(const int flags);

/**
* Retrieve any OpenSSL errors, then print= the supplied error message.
diff --git a/src/openvpn/error= .c b/src/openvpn/error.c
index 1b98235..8043afe 100644
--- a/src/openvpn/error.c
+++ b/src/openvpn/err= or.c
@@ -48,7 +48,7 @@
#endif

/* Globals */
-unsigned int x_debug_level; /* GLOBAL */
+int x_debug_level; /* GLOBAL */<= br>
/* Mute state */
static int mu= te_cutoff; /* GLOBAL */
@@ -101,7 +101,7 @@
}


bool
-set_debug_level(const int level, const unsigned int= flags)
+set_debug_le= vel(const int level, const int flags)
{
= const int ceiling =3D 15;

@@ -190,7 +1= 90,7 @@
* Return a file to print messages to before syslo= g is opened.
*/
FILE *
-msg_fp(const unsigned int flags)=
+msg_fp(const int flags)
{
FILE *fp =3D msgfp;
= if (!fp)
@@ -214,7 +214,7 @@
int x_msg= _line_num; /* GLOBAL */

void
<= span style=3D"color: hsl(0, 100%, 40%);">-x_msg(const unsigned int flags, c= onst char *format, ...)

+x_msg(const int flags, const char *format, ...)
{
va_list arglist;
va_start(arglist, fo= rmat);
@@ -235,7 +235,7 @@
}

void
-x_msg_va(const unsigned int flags, const char *format, va_list arglist= )
+x_msg_va(const int= flags, const char *format, va_list arglist)
{
<= span> struct gc_arena gc;

#if SYSLOG_CAPABILITY=
@@ -385,7 +385,7 @@
* Apply muting filter.
*/
bool
-dont_mute(unsigned int flags)
+dont_mute(int flags)
{ bool ret =3D true;
if (mute_cutoff > 0= && !(flags & M_NOMUTE))
@@ -599,9 +599,9 @@
* of I/O operations.
*/
=
-unsigned int x_cs_inf= o_level; /* GLOBAL */
-unsigned int x_cs_err_delay_ms; /* GLOBAL */
+int x_cs_info_level; = /* GLOBAL */
+unsigned int x_cs_err_delay_ms; /* GLOBAL */

void
reset_check_status(v= oid)
@@ -611,7 +611,7 @@
}

void
+set_check_status(int i= nfo_level, int verbose_level)
{
x_cs_= info_level =3D info_level;
x_cs_verbose_level =3D verb= ose_level;
@@ -750,7 +750,7 @@
* Translat= e msg flags into a string
*/
const char = *
-msg_flags_string(con= st unsigned int flags, struct gc_arena *gc)
+msg_flags_string(const int flags, struct gc_arena *= gc)
{
struct buffer out =3D alloc_buf= _gc(16, gc);
if (flags =3D=3D M_INFO)
= diff --git a/src/openvpn/error.h b/src/openvpn/error.h
inde= x 8388f82..babb42f 100644
--- a/src/openvpn/error.h<= br>+++ b/src/openvpn/error.h
@@ -78,7 +78,7 @@=
* These globals should not be accessed directly,
* but rather through macros or inline functions defined below.
*/
-extern un= signed int x_debug_level;
+extern int x_debug_level;
extern int x_msg_line_num;=

/* msg() flags */
@@ -1= 35,7 +135,7 @@
*/

/** = Check muting filter */
= -bool dont_mute(unsigned int flags);
+bool dont_mute(int flags);

/* Macro to ensure (and teach static analysis tools) we exit on fatal e= rrors */

#define EXIT_FATAL(flags) \
= @@ -170,7 +170,7 @@
#define dmsg(flags, ...)
#endif


-void x_msg(const unsigned int flags, const char *format, ...)=
+void x_msg(const int flags= , const char *format, ...)
#ifdef __GNUC__
#if __USE_MINGW_ANSI_STDIO

__attribute__((format(gnu= _printf, 2, 3)))
@@ -180,7 +180,7 @@
#endi= f
; /* should be called via msg above */

-void x_msg_va(con= st unsigned int flags, const char *format, va_list arglist);
+void x_msg_va(const int flags, con= st char *format, va_list arglist);

/*
* Function prototypes
@@ -197,7 +197,7 @@


#define SDL_CONSTRAIN (= 1 << 0)
-bool set= _debug_level(const int level, const unsigned int flags);
+bool set_debug_level(const int level, = const int flags);

bool set_mute_cutoff(c= onst int cutoff);

@@ -205,12 +205,12 @@

int get_mute_cutoff(void);

-const char *msg_fl= ags_string(const unsigned int flags, struct gc_arena *gc);
+const char *msg_flags_string(const i= nt flags, struct gc_arena *gc);

/*
* File to print messages to before syslog is opened. */
-FILE *msg_= fp(const unsigned int flags);
+FILE *msg_fp(const int flags);

= /* Fatal logic errors */
#ifndef ENABLE_SMALL
<= span>@@ -254,14 +254,14 @@

/* Inline functions */
static inline bool
-check_debug_level(unsigned int level)
+check_debug_level(int level)

{
return (level & M_DEBUG_LEVEL) <= =3D x_debug_level;
}

/*= * Return true if flags represent an enabled, not muted log level */<= br> static inline bool
-msg_test(unsigned int flags)
+msg_test(int flags)
{
= return check_debug_level(flags) && dont_mute(flags);
}
@@ -297,13 +297,13 @@
struct link_so= cket;
struct tuntap;

-extern unsigned int x_cs_info_level;
-extern unsigned int x_cs_v= erbose_level;
+extern= int x_cs_info_level;
+extern int x_cs_verbose_level;
extern unsigned int x_cs_= err_delay_ms;

void reset_check_status(vo= id);

= -void set_check_status(unsigned int info_level, unsigned int verbose_level)= ;
+void set_check_sta= tus(int info_level, int verbose_level);

= void x_check_status(int status, const char *description, struct link_socket= *sock,
struct tuntap *tt);
= @@ -400,8 +400,8 @@
}

/** Convert fatal errors to nonfatal, don't touch other errors */<= /span>
-static inline unsigned= int
-nonfatal(const un= signed int err)
+stat= ic inline int
+nonfat= al(const int err)
{
return err & = M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err;
}
= @@ -409,21 +409,20 @@
static inline int
openvpn_errno_maybe_crt(bool *crt_error)

{
= - int err =3D 0;
*crt_error =3D false;
#ifdef _WIN32
- err =3D GetLastError();+ int err =3D (int)GetLast= Error();
if (err =3D=3D ERROR_SUCCESS)
{
/* error is likely C runtime */
= *crt_error =3D true;
err =3D errno;=
}
+ return err;
#else /* ifdef _WIN32 */
*crt_error =3D true;
- err =3D errno;
+ return errno;
#endif
- return err;
}

#include "errlevel.h"
diff -= -git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 4f= 37bd2..87981d2 100644
--- a/src/openvpn/manage.c
= +++ b/src/openvpn/manage.c
@@ -352,7 +352,7 @@=
}

static void
-virtual_output_callback_func(void *ar= g, const unsigned int flags, const char *str)
+virtual_output_callback_func(void *arg, const int= flags, const char *str)
{
struct man= agement *man =3D (struct management *)arg;
static int = recursive_level =3D 0; /* GLOBAL */
diff --git a/src/openvp= n/manage.h b/src/openvpn/manage.h
index 7c189ba..7196210 10= 0644
--- a/src/openvpn/manage.h
+++ b/src/o= penvpn/manage.h
@@ -98,7 +98,7 @@
<= br> union log_entry_union
{
- unsigned int msg_flags;
+ int msg_flags;
= int state;
int intval;
};diff --git a/src/openvpn/options.c b/src/openvpn/options.cindex e47d54c..22b36a3 100644
--- a/src/openvpn/opti= ons.c
+++ b/src/openvpn/options.c
@@ -4869,= 7 +4869,7 @@

#ifdef _WIN32
void
-show_windows_= version(const unsigned int flags)
+show_windows_version(const int flags)
{

struct gc_arena gc =3D gc_new();
msg(= flags, "Windows version: %s", win32_version_string(&gc));

@@ -4878,7 +4878,7 @@
#endif
=
void
-show_dco_version(const unsigned int flags)
+show_dco_version(const int flags)
= {
#ifdef ENABLE_DCO
struct gc_arena = gc =3D gc_new();
@@ -4888,7 +4888,7 @@
}

void
-show_library_versions(const unsigned int flags)
= +show_library_versions(const in= t flags)
{
#ifdef ENABLE_LZO
#define LZO_LIB_VER_STR ", LZO ", lzo_version_string()

diff --git a/src/openvpn/options.h b/src/openvpn/options.h
index bb2c052..b8efdf8 100644
--- a/src/openvpn/= options.h
+++ b/src/openvpn/options.h
@@ -8= 30,14 +830,14 @@

void usage_small(void);=

-voi= d show_library_versions(const unsigned int flags);
+void show_library_versions(const int flags);=

#ifdef _WIN32
-void show_windows_version(const unsigned int fl= ags);
+void show_wind= ows_version(const int flags);

#endif


-void sh= ow_dco_version(const unsigned int flags);
+void show_dco_version(const int flags);

void init_options(struct options *o, const bool init_= gc);

diff --git a/src/openvpn/pkcs11.c b/= src/openvpn/pkcs11.c
index d9c16d9..ba81c54 100644--- a/src/openvpn/pkcs11.c
+++ b/src/openvpn/pkcs11= .c
@@ -77,10 +77,10 @@
#endif
};

-static unsigned
-_p= kcs11_msg_pkcs112openvpn(const unsigned flags)
+static int
+_pkcs11_msg_pkcs112openvpn(const unsigned int flags)
{
- uns= igned openvpn_flags;
= + int openvpn_flags;

switch (flag= s)
{
@@ -117,7 +117,7 @@
}


static unsigned
-_pkcs11_msg_openvpn2pkcs11(const unsigne= d flags)
+_pkcs11_msg= _openvpn2pkcs11(const int flags)
{
un= signed pkcs11_flags;

diff --git a/src/ope= nvpn/platform.c b/src/openvpn/platform.c
index 880d14e..78c= 56d3 100644
--- a/src/openvpn/platform.c
++= + b/src/openvpn/platform.c
@@ -223,7 +223,7 @@
const struct platform_state_group *group_state= , struct context *c)
{
int keep_caps = =3D need_keep_caps(c);
= - unsigned int err_flags =3D (keep_caps > 0) ? M_FATAL : M_NONFATAL;<= /span>
+ int err_flags = =3D (keep_caps > 0) ? M_FATAL : M_NONFATAL;
#ifdef HAVE= _LIBCAPNG
int new_gid =3D -1, new_uid =3D -1; int res;
diff --git a/src/openvpn/plugin.c b/s= rc/openvpn/plugin.c
index ea76a08..b14ce5c 100644--- a/src/openvpn/plugin.c
+++ b/src/openvpn/plugin.= c
@@ -371,7 +371,7 @@
static void plugin_vlog(openvpn_plugin_log_flags_t flags, const char *name, co= nst char *format, va_list arglist)
{
- unsigned int msg_flags =3D 0;+ int msg_flags =3D 0;

if (!format)
{
diff --git a/src/openvpn/proto.c b/src/openvpn/proto.cindex 34b3378..b0373df 100644
--- a/src/openvpn/pro= to.c
+++ b/src/openvpn/proto.c
@@ -183,7 +1= 83,7 @@
int hlen;
= int totlen;
const char *msgstr =3D "PACK= ET SIZE INFO";
- = unsigned int msglevel =3D D_PACKET_TRUNC_DEBUG;
+ int msglevel =3D D_PACKET= _TRUNC_DEBUG;

if (BLEN(&= buf) < (int)sizeof(struct openvpn_iphdr))
{=
diff --git a/src/openvpn/status.h b/src/openvpn/status.h
index 0c7a869..c318683 100644
--- a/src/open= vpn/status.h
+++ b/src/openvpn/status.h
@@ = -32,11 +32,11 @@
{
void *arg;<= br> unsigned int flags_default;
- void (*func)(void *arg, const unsigned int flags, c= onst char *str);
+ = void (*func)(void *arg, const int flags, const char *str);
};


static inline void
-virtual_output_print(const struct virt= ual_output *vo, const unsigned int flags, const char *str)
+virtual_output_print(const struct vi= rtual_output *vo, const int flags, const char *str)
{
(*vo->func)(vo->arg, flags, str);
}=
diff --git a/src/openvpnmsica/dllmain.c b/src/openvpnmsica= /dllmain.c
index e7d4a4b..8b1b7e9 100644
--= - a/src/openvpnmsica/dllmain.c
+++ b/src/openvpnmsica/dllma= in.c
@@ -91,7 +91,7 @@

<= /span>
bool
-= dont_mute(unsigned int flags)
+dont_mute(int flags)
{
UNRE= FERENCED_PARAMETER(flags);

@@ -100,7 +100= ,7 @@


void
<= span style=3D"color: hsl(0, 100%, 40%);">-x_msg_va(const unsigned int flags= , const char *format, va_list arglist)

+x_msg_va(const int flags, const char *format, va_list ar= glist)
{
/* Secure last error before = it is overridden. */
DWORD dwResult =3D (flags & M= _ERRNO) !=3D 0 ? GetLastError() : ERROR_SUCCESS;
diff --git= a/src/tapctl/error.c b/src/tapctl/error.c
index 9f5094e..2= 7a475a 100644
--- a/src/tapctl/error.c
+++ = b/src/tapctl/error.c
@@ -22,11 +22,11 @@
<= /span>

/* Globals */
-unsigned int x_debug_level; /* GLOBAL */<= br>+int x_debug_level; /* GLOBA= L */


void
-x_msg(const unsigned int flags, co= nst char *format, ...)

-extern unsigned int x_debug_level;
+extern int x_debug_level;
extern i= nt x_msg_line_num;

/* msg() flags */

@@ -58,7 +58,7 @@

/** Check muting filter */
-bool dont_mute(unsigned int flags);
+bool dont_mute(int flags);
<= /span>
/* Macro to ensure (and teach static analysis tools) we ex= it on fatal errors */
#ifdef _MSC_VER
@@ -= 97,21 +97,21 @@
#define dmsg(flags, ...)
= #endif

+void x_msg(const int flags, const char *format, ...); /* should be = called via msg above */

-void x_msg_va(const unsigned int flags, const char *for= mat, va_list arglist);
-check_debug_level(unsigned int level)
+check_debug_level(int level)
= {
return (level & M_DEBUG_LEVEL) <=3D x_debug_= level;
}

/** Return tru= e if flags represent and enabled, not muted log level */
s= tatic inline bool
-msg_= test(unsigned int flags)
+msg_test(int flags)
{
return che= ck_debug_level(flags) && dont_mute(flags);
}
diff --git a/src/tapctl/main.c b/src/tapctl/main.c
index 031e262..52cc8e22 100644

--- a/src/tapctl/main.c
+++ b/src/tapctl/main.c
@@ -479,7 +479,7 @@<= /span>


bool
-dont_mute(unsigned int flags)+dont_mute(int flags) {
UNREFERENCED_PARAMETER(flags);

@@ -488,7 +488,7 @@


void
+x_msg_va(const int f= lags, const char *format, va_list arglist)
{
/* Output message string. Note: Message strings don't contain l= ine terminators. */

vfprintf(stderr, format, arglist);=
diff --git a/tests/unit_tests/openvpn/mock_msg.c b/tests/u= nit_tests/openvpn/mock_msg.c
index 603520b..a2d9c72 100644<= /span>
--- a/tests/unit_tests/openvpn/mock_msg.c
+= ++ b/tests/unit_tests/openvpn/mock_msg.c
@@ -38,8 +38,8 @@<= /span>
#include "error.h"
#include &qu= ot;mock_msg.h"

-unsigned int x_debug_level =3D 0; /* Default to (almost) no= debugging output */
-u= nsigned int print_x_debug_level =3D 0;
+int x_debug_level =3D 0; /* Default to (almost) no debug= ging output */
+int p= rint_x_debug_level =3D 0;

bool fatal_err= or_triggered =3D false;

@@ -71,7 +71,7 @@=
}

void
-x_msg_va(const unsigned int flags, co= nst char *format, va_list arglist)

+x_msg_va(const int flags, const char *format, va_list arglis= t)
{
if (flags & M_FATAL)<= br> {
@@ -89,7 +89,7 @@
}=

void
-x_msg(const unsigned int flags, const char *format, ...)=
+x_msg(const int flags, con= st char *format, ...)
{
va_list argli= st;
va_start(arglist, format);
@@ -128= ,7 +128,7 @@
}

bool

-dont_mute(unsigned int fl= ags)
+dont_mute(int f= lags)
{
return true;
= }
diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b= /tests/unit_tests/openvpn/test_cryptoapi.c
index 6e83465..c= ff9547 100644
--- a/tests/unit_tests/openvpn/test_cryptoapi= .c
+++ b/tests/unit_tests/openvpn/test_cryptoapi.c@@ -59,7 +59,7 @@

/* replacement= for crypto_print_openssl_errors() */
void
-crypto_print_openssl_errors(const uns= igned int flags)
+cry= pto_print_openssl_errors(const int flags)
{
unsigned long e;
while ((e =3D ERR_get_error())= )
diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tes= ts/unit_tests/openvpn/test_pkcs11.c
index 9ba6cfc..961d78b = 100644
--- a/tests/unit_tests/openvpn/test_pkcs11.c<= br>+++ b/tests/unit_tests/openvpn/test_pkcs11.c
@@ -4= 7,7 +47,7 @@

/* replacement for crypto_p= rint_openssl_errors() */
void
-crypto_print_openssl_errors(const unsigned int fla= gs)
+crypto_print_ope= nssl_errors(const int flags)
{
unsign= ed long e;
while ((e =3D ERR_get_error()))
<= span>

To view, visit change 1189. To unsubscribe, or for hel= p writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4b0078d099e975d223825194ad1= 04945b1247554
Gerrit-Change-Number: 1189
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-MessageType: newchange
--weuBPlnz8+M=--