From: flichtenheld (C. Review) <ge...@op...> - 2025-07-24 13:45:28
|
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/+/1110?usp=email to review the following change. Change subject: Clean up the big msglevel type confusion ...................................................................... Clean up the big msglevel type confusion msglevel was definitely unsigned as the first argument to msg(), but many parts of the code had it as signed. So this produced a LOT of warnings when enabling -Wsign-conversion. There is one exception in struct status_output where -1 is a valid value in the API. Only positive values are translated into standard message levels. Change-Id: Id492cb774c6d022d06bb3cf5fec2a4bdd410e619 Signed-off-by: Frank Lichtenheld <fr...@li...> --- M src/openvpn/argv.c M src/openvpn/argv.h M src/openvpn/buffer.c M src/openvpn/clinat.c M src/openvpn/clinat.h M src/openvpn/comp.c M src/openvpn/comp.h M src/openvpn/crypto.c M src/openvpn/crypto.h M src/openvpn/dco.c M src/openvpn/dco.h M src/openvpn/dco_freebsd.c M src/openvpn/dco_linux.c M src/openvpn/dco_win.c M src/openvpn/dns.c M src/openvpn/dns.h M src/openvpn/env_set.c M src/openvpn/env_set.h M src/openvpn/error.c M src/openvpn/error.h M src/openvpn/forward.c M src/openvpn/forward.h M src/openvpn/init.c M src/openvpn/init.h M src/openvpn/manage.h M src/openvpn/multi.c M src/openvpn/options.c M src/openvpn/options.h M src/openvpn/options_util.c M src/openvpn/options_util.h M src/openvpn/packet_id.c M src/openvpn/plugin.c M src/openvpn/plugin.h M src/openvpn/pool.c M src/openvpn/pool.h M src/openvpn/push.c M src/openvpn/push.h M src/openvpn/route.c M src/openvpn/route.h M src/openvpn/run_command.c M src/openvpn/run_command.h M src/openvpn/sig.c M src/openvpn/sig.h M src/openvpn/socket.c M src/openvpn/socket.h M src/openvpn/ssl_verify_backend.h M src/openvpn/ssl_verify_mbedtls.c M src/openvpn/ssl_verify_openssl.c M src/openvpn/status.c M src/openvpn/status.h M src/openvpn/tun.c M src/openvpn/tun.h M tests/unit_tests/openvpn/mock_ssl_dependencies.c M tests/unit_tests/openvpn/test_argv.c M tests/unit_tests/openvpn/test_misc.c M tests/unit_tests/openvpn/test_pkcs11.c M tests/unit_tests/openvpn/test_pkt.c M tests/unit_tests/openvpn/test_tls_crypt.c M tests/unit_tests/openvpn/test_user_pass.c 59 files changed, 185 insertions(+), 185 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/10/1110/1 diff --git a/src/openvpn/argv.c b/src/openvpn/argv.c index 95215c0..2db510c 100644 --- a/src/openvpn/argv.c +++ b/src/openvpn/argv.c @@ -236,14 +236,14 @@ /** * Write the arguments stored in a struct argv via the msg() command. * - * @param msglev Integer with the message level used by msg(). - * @param a Valid pointer to the struct argv with the arguments to write. + * @param msglevel Integer with the message level used by msg(). + * @param a Valid pointer to the struct argv with the arguments to write. */ void -argv_msg(const int msglev, const struct argv *a) +argv_msg(const unsigned int msglevel, const struct argv *a) { struct gc_arena gc = gc_new(); - msg(msglev, "%s", argv_str(a, &gc, 0)); + msg(msglevel, "%s", argv_str(a, &gc, 0)); gc_free(&gc); } @@ -251,16 +251,16 @@ * Similar to argv_msg() but prefixes the messages being written with a * given string. * - * @param msglev Integer with the message level used by msg(). - * @param a Valid pointer to the struct argv with the arguments to write - * @param prefix Valid pointer to the prefix string + * @param msglevel Integer with the message level used by msg(). + * @param a Valid pointer to the struct argv with the arguments to write + * @param prefix Valid pointer to the prefix string * */ void -argv_msg_prefix(const int msglev, const struct argv *a, const char *prefix) +argv_msg_prefix(const unsigned int msglevel, const struct argv *a, const char *prefix) { struct gc_arena gc = gc_new(); - msg(msglev, "%s: %s", prefix, argv_str(a, &gc, 0)); + msg(msglevel, "%s: %s", prefix, argv_str(a, &gc, 0)); gc_free(&gc); } diff --git a/src/openvpn/argv.h b/src/openvpn/argv.h index 098a1cb..866b405 100644 --- a/src/openvpn/argv.h +++ b/src/openvpn/argv.h @@ -47,9 +47,9 @@ struct argv argv_insert_head(const struct argv *a, const char *head); -void argv_msg(const int msglev, const struct argv *a); +void argv_msg(const unsigned int msglevel, const struct argv *a); -void argv_msg_prefix(const int msglev, const struct argv *a, const char *prefix); +void argv_msg_prefix(const unsigned int msglevel, const struct argv *a, const char *prefix); void argv_parse_cmd(struct argv *a, const char *s); diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index dd6044b..456f591 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -1130,7 +1130,7 @@ { if (buf && buf->len) { - int msglevel = D_ALIGN_DEBUG; + unsigned int msglevel = D_ALIGN_DEBUG; const unsigned int u = (unsigned int) BPTR(buf); if (u & (PAYLOAD_ALIGN-1)) diff --git a/src/openvpn/clinat.c b/src/openvpn/clinat.c index f040724..81af08c 100644 --- a/src/openvpn/clinat.c +++ b/src/openvpn/clinat.c @@ -49,7 +49,7 @@ } void -print_client_nat_list(const struct client_nat_option_list *list, int msglevel) +print_client_nat_list(const struct client_nat_option_list *list, unsigned int msglevel) { struct gc_arena gc = gc_new(); int i; @@ -108,7 +108,7 @@ const char *network, const char *netmask, const char *foreign_network, - int msglevel) + unsigned int msglevel) { struct client_nat_entry e; bool ok; @@ -166,7 +166,7 @@ #endif static void -print_pkt(struct openvpn_iphdr *iph, const char *prefix, const int direction, const int msglevel) +print_pkt(struct openvpn_iphdr *iph, const char *prefix, const int direction, const unsigned int msglevel) { struct gc_arena gc = gc_new(); diff --git a/src/openvpn/clinat.h b/src/openvpn/clinat.h index 334b3f2..c099857 100644 --- a/src/openvpn/clinat.h +++ b/src/openvpn/clinat.h @@ -51,14 +51,14 @@ void copy_client_nat_option_list(struct client_nat_option_list *dest, const struct client_nat_option_list *src); -void print_client_nat_list(const struct client_nat_option_list *list, int msglevel); +void print_client_nat_list(const struct client_nat_option_list *list, unsigned int msglevel); void add_client_nat_to_option_list(struct client_nat_option_list *dest, const char *type, const char *network, const char *netmask, const char *foreign_network, - int msglevel); + unsigned int msglevel); void client_nat_transform(const struct client_nat_option_list *list, struct buffer *ipbuf, diff --git a/src/openvpn/comp.c b/src/openvpn/comp.c index b2aa07e..2e17af4 100644 --- a/src/openvpn/comp.c +++ b/src/openvpn/comp.c @@ -160,7 +160,7 @@ #endif /* USE_COMP */ bool -check_compression_settings_valid(struct compress_options *info, int msglevel) +check_compression_settings_valid(struct compress_options *info, unsigned int msglevel) { /* * We also allow comp-stub-v2 here as it technically allows escaping of diff --git a/src/openvpn/comp.h b/src/openvpn/comp.h index ee9c16a..37f3be7 100644 --- a/src/openvpn/comp.h +++ b/src/openvpn/comp.h @@ -91,7 +91,7 @@ * in */ bool -check_compression_settings_valid(struct compress_options *info, int msglevel); +check_compression_settings_valid(struct compress_options *info, unsigned int msglevel); #ifdef USE_COMP #include "buffer.h" diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 7564f82..91b5da04 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -1650,7 +1650,7 @@ } int -ascii2keydirection(int msglevel, const char *str) +ascii2keydirection(unsigned int msglevel, const char *str) { if (!str) { diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h index 345e7ce..cd32bb4 100644 --- a/src/openvpn/crypto.h +++ b/src/openvpn/crypto.h @@ -627,7 +627,7 @@ void must_have_n_keys(const char *filename, const char *option, const struct key2 *key2, int n); -int ascii2keydirection(int msglevel, const char *str); +int ascii2keydirection(unsigned int msglevel, const char *str); const char *keydirection2ascii(int kd, bool remote, bool humanreadable); diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 98cbb72..6ce86a2 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -239,7 +239,7 @@ } static bool -dco_check_option_ce(const struct connection_entry *ce, int msglevel, int mode) +dco_check_option_ce(const struct connection_entry *ce, unsigned int msglevel, int mode) { if (ce->fragment) { @@ -297,7 +297,7 @@ } bool -dco_check_startup_option(int msglevel, const struct options *o) +dco_check_startup_option(unsigned int msglevel, const struct options *o) { /* check if no dev name was specified at all. In the case, * later logic will most likely stop OpenVPN, so no need to @@ -433,7 +433,7 @@ } bool -dco_check_option(int msglevel, const struct options *o) +dco_check_option(unsigned int msglevel, const struct options *o) { /* At this point the ciphers have already been normalised */ if (o->enable_ncp_fallback @@ -479,7 +479,7 @@ } bool -dco_check_pull_options(int msglevel, const struct options *o) +dco_check_pull_options(unsigned int msglevel, const struct options *o) { if (!o->use_peer_id) { diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h index f38316d..3dbf19c 100644 --- a/src/openvpn/dco.h +++ b/src/openvpn/dco.h @@ -56,7 +56,7 @@ * @param msglevel level to print messages to * @return true if ovpn-dco is available, false otherwise */ -bool dco_available(int msglevel); +bool dco_available(unsigned int msglevel); /** @@ -76,7 +76,7 @@ * @param o the options struct that hold the options * @return true if no conflict was detected, false otherwise */ -bool dco_check_option(int msglevel, const struct options *o); +bool dco_check_option(unsigned int msglevel, const struct options *o); /** * Check whether the options struct has any further option that is not supported @@ -88,7 +88,7 @@ * @param o the options struct that hold the options * @return true if no conflict was detected, false otherwise */ -bool dco_check_startup_option(int msglevel, const struct options *o); +bool dco_check_startup_option(unsigned int msglevel, const struct options *o); /** * Check whether any of the options pushed by the server is not supported by @@ -99,7 +99,7 @@ * @param o the options struct that hold the options * @return true if no conflict was detected, false otherwise */ -bool dco_check_pull_options(int msglevel, const struct options *o); +bool dco_check_pull_options(unsigned int msglevel, const struct options *o); /** * Initialize the DCO context @@ -267,7 +267,7 @@ typedef void *dco_context_t; static inline bool -dco_available(int msglevel) +dco_available(unsigned int msglevel) { return false; } @@ -279,19 +279,19 @@ } static inline bool -dco_check_option(int msglevel, const struct options *o) +dco_check_option(unsigned int msglevel, const struct options *o) { return false; } static inline bool -dco_check_startup_option(int msglevel, const struct options *o) +dco_check_startup_option(unsigned int msglevel, const struct options *o) { return false; } static inline bool -dco_check_pull_options(int msglevel, const struct options *o) +dco_check_pull_options(unsigned int msglevel, const struct options *o) { return false; } diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index b8816c6..bcd10b7 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -582,7 +582,7 @@ } bool -dco_available(int msglevel) +dco_available(unsigned int msglevel) { struct if_clonereq ifcr; char *buf = NULL; diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 3652a49..43753a5 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -76,7 +76,7 @@ * @return ID on success, negative error code on error */ static int -resolve_ovpn_netlink_id(int msglevel) +resolve_ovpn_netlink_id(unsigned int msglevel) { int ret; struct nl_sock *nl_sock = nl_socket_alloc(); @@ -1196,7 +1196,7 @@ } bool -dco_available(int msglevel) +dco_available(unsigned int msglevel) { if (resolve_ovpn_netlink_id(D_DCO_DEBUG) < 0) { diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index 83db739..15f7237 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -598,7 +598,7 @@ } bool -dco_available(int msglevel) +dco_available(unsigned int msglevel) { /* try to open device by symbolic name */ HANDLE h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRITE, diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c index ea3d91b..271186e 100644 --- a/src/openvpn/dns.c +++ b/src/openvpn/dns.c @@ -201,7 +201,7 @@ } bool -dns_options_verify(int msglevel, const struct dns_options *o) +dns_options_verify(unsigned int msglevel, const struct dns_options *o) { const struct dns_server *server = o->servers ? o->servers : o->servers_prepull; diff --git a/src/openvpn/dns.h b/src/openvpn/dns.h index d33f64e..ee70ed8 100644 --- a/src/openvpn/dns.h +++ b/src/openvpn/dns.h @@ -157,7 +157,7 @@ * @param o Pointer to the DNS options to validate * @return True if no error was found */ -bool dns_options_verify(int msglevel, const struct dns_options *o); +bool dns_options_verify(unsigned int msglevel, const struct dns_options *o); /** * Makes a deep copy of the passed DNS options. diff --git a/src/openvpn/env_set.c b/src/openvpn/env_set.c index f20ee8a..cbf7d8f 100644 --- a/src/openvpn/env_set.c +++ b/src/openvpn/env_set.c @@ -210,7 +210,7 @@ } void -env_set_print(int msglevel, const struct env_set *es) +env_set_print(unsigned int msglevel, const struct env_set *es) { if (check_debug_level(msglevel)) { diff --git a/src/openvpn/env_set.h b/src/openvpn/env_set.h index 52c5312..42ebff0 100644 --- a/src/openvpn/env_set.h +++ b/src/openvpn/env_set.h @@ -89,7 +89,7 @@ const char *env_set_get(const struct env_set *es, const char *name); -void env_set_print(int msglevel, const struct env_set *es); +void env_set_print(unsigned int msglevel, const struct env_set *es); /** * Write a struct env_set to a file. Each item on one line. diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 049cd92..170076a 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -409,8 +409,8 @@ bool ret = true; if (mute_cutoff > 0 && !(flags & M_NOMUTE)) { - const int mute_level = DECODE_MUTE_LEVEL(flags); - if (mute_level > 0 && mute_level == mute_category) + const unsigned int mute_level = DECODE_MUTE_LEVEL(flags); + if (mute_level == mute_category) { if (mute_count == mute_cutoff) { diff --git a/src/openvpn/error.h b/src/openvpn/error.h index e0a2730..7744ef8 100644 --- a/src/openvpn/error.h +++ b/src/openvpn/error.h @@ -84,22 +84,22 @@ /* msg() flags */ -#define M_DEBUG_LEVEL (0x0F) /* debug level mask */ +#define M_DEBUG_LEVEL (0x0Fu) /* debug level mask */ -#define M_FATAL (1<<4) /* exit program */ -#define M_NONFATAL (1<<5) /* non-fatal error */ -#define M_WARN (1<<6) /* call syslog with LOG_WARNING */ -#define M_DEBUG (1<<7) +#define M_FATAL (1u<<4) /* exit program */ +#define M_NONFATAL (1u<<5) /* non-fatal error */ +#define M_WARN (1u<<6) /* call syslog with LOG_WARNING */ +#define M_DEBUG (1u<<7) -#define M_ERRNO (1<<8) /* show errno description */ +#define M_ERRNO (1u<<8) /* show errno description */ -#define M_NOMUTE (1<<11) /* don't do mute processing */ -#define M_NOPREFIX (1<<12) /* don't show date/time prefix */ -#define M_USAGE_SMALL (1<<13) /* fatal options error, call usage_small */ -#define M_MSG_VIRT_OUT (1<<14) /* output message through msg_status_output callback */ -#define M_OPTERR (1<<15) /* print "Options error:" prefix */ -#define M_NOLF (1<<16) /* don't print new line */ -#define M_NOIPREFIX (1<<17) /* don't print instance prefix */ +#define M_NOMUTE (1u<<11) /* don't do mute processing */ +#define M_NOPREFIX (1u<<12) /* don't show date/time prefix */ +#define M_USAGE_SMALL (1u<<13) /* fatal options error, call usage_small */ +#define M_MSG_VIRT_OUT (1u<<14) /* output message through msg_status_output callback */ +#define M_OPTERR (1u<<15) /* print "Options error:" prefix */ +#define M_NOLF (1u<<16) /* don't print new line */ +#define M_NOIPREFIX (1u<<17) /* don't print instance prefix */ /* flag combinations which are frequently used */ #define M_ERR (M_FATAL | M_ERRNO) @@ -113,7 +113,7 @@ * A mute level of 0 is always printed. */ #define MUTE_LEVEL_SHIFT 24 -#define MUTE_LEVEL_MASK 0xFF +#define MUTE_LEVEL_MASK 0xFFu #define ENCODE_MUTE_LEVEL(mute_level) (((mute_level) & MUTE_LEVEL_MASK) << MUTE_LEVEL_SHIFT) #define DECODE_MUTE_LEVEL(flags) (((flags) >> MUTE_LEVEL_SHIFT) & MUTE_LEVEL_MASK) diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index dfc6708..aab195d 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -379,7 +379,7 @@ bool send_control_channel_string_dowork(struct tls_session *session, - const char *str, int msglevel) + const char *str, unsigned int msglevel) { struct gc_arena gc = gc_new(); bool stat; @@ -407,7 +407,7 @@ } bool -send_control_channel_string(struct context *c, const char *str, int msglevel) +send_control_channel_string(struct context *c, const char *str, unsigned int msglevel) { if (c->c2.tls_multi) { diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index b3e424c..aaf47fe 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -287,7 +287,7 @@ * @param msglevel - Message level to use for logging */ bool -send_control_channel_string(struct context *c, const char *str, int msglevel); +send_control_channel_string(struct context *c, const char *str, unsigned int msglevel); /* * Send a string to remote over the TLS control channel. @@ -307,7 +307,7 @@ bool send_control_channel_string_dowork(struct tls_session *session, - const char *str, int msglevel); + const char *str, unsigned int msglevel); /** diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 77747a2..641d7ee 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -4379,7 +4379,7 @@ } void -management_show_net_callback(void *arg, const int msglevel) +management_show_net_callback(void *arg, const unsigned int msglevel) { #ifdef _WIN32 show_routes(msglevel); diff --git a/src/openvpn/init.h b/src/openvpn/init.h index 5c6b9c1..40d8d04 100644 --- a/src/openvpn/init.h +++ b/src/openvpn/init.h @@ -125,7 +125,7 @@ void close_management(void); -void management_show_net_callback(void *arg, const int msglevel); +void management_show_net_callback(void *arg, const unsigned int msglevel); #endif diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index e25a615..3b4c18c 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -178,7 +178,7 @@ unsigned int flags; void (*status) (void *arg, const int version, struct status_output *so); - void (*show_net) (void *arg, const int msglevel); + void (*show_net) (void *arg, const unsigned int msglevel); int (*kill_by_cn) (void *arg, const char *common_name); int (*kill_by_addr) (void *arg, const in_addr_t addr, const int port, const int proto); void (*delete_event) (void *arg, event_t event); diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index ec260a2..b84f663 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -3419,7 +3419,7 @@ } else { - int msglevel = D_DCO; + unsigned int msglevel = D_DCO; if (dco->dco_message_type == OVPN_CMD_DEL_PEER && dco->dco_del_peer_reason == OVPN_DEL_PEER_REASON_USERSPACE) { diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0662b49..70b5799 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -1106,7 +1106,7 @@ #endif /* ifndef _WIN32 */ static in_addr_t -get_ip_addr(const char *ip_string, int msglevel, bool *error) +get_ip_addr(const char *ip_string, unsigned int msglevel, bool *error) { unsigned int flags = GETADDR_HOST_ORDER; bool succeeded = false; @@ -1187,7 +1187,7 @@ * @param gc The returned object will be allocated in this gc */ static struct verify_hash_list * -parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_arena *gc) +parse_hash_fingerprint(const char *str, int nbytes, unsigned int msglevel, struct gc_arena *gc) { int i = 0; const char *cp = str; @@ -1241,7 +1241,7 @@ * @param gc The returned list items will be allocated in this gc */ static struct verify_hash_list * -parse_hash_fingerprint_multiline(const char *str, int nbytes, int msglevel, +parse_hash_fingerprint_multiline(const char *str, int nbytes, unsigned int msglevel, struct gc_arena *gc) { struct gc_arena gc_temp = gc_new(); @@ -1335,7 +1335,7 @@ #endif /* ifdef _WIN32 */ static void -dhcp_option_dns6_parse(const char *parm, struct in6_addr *dns6_list, int *len, int msglevel) +dhcp_option_dns6_parse(const char *parm, struct in6_addr *dns6_list, int *len, unsigned int msglevel) { struct in6_addr addr; if (*len >= N_DHCP_ADDR) @@ -1349,7 +1349,7 @@ } } static void -dhcp_option_address_parse(const char *name, const char *parm, in_addr_t *array, int *len, int msglevel) +dhcp_option_address_parse(const char *name, const char *parm, in_addr_t *array, int *len, unsigned int msglevel) { if (*len >= N_DHCP_ADDR) { @@ -1480,7 +1480,7 @@ option_iroute(struct options *o, const char *network_str, const char *netmask_str, - int msglevel) + unsigned int msglevel) { struct iroute *ir; @@ -1509,7 +1509,7 @@ static void option_iroute_ipv6(struct options *o, const char *prefix_str, - int msglevel) + unsigned int msglevel) { struct iroute_ipv6 *ir; @@ -2068,7 +2068,7 @@ } static struct local_entry * -alloc_local_entry(struct connection_entry *ce, const int msglevel, +alloc_local_entry(struct connection_entry *ce, const unsigned int msglevel, struct gc_arena *gc) { struct local_list *l = alloc_local_list_if_undef(ce, gc); @@ -2108,7 +2108,7 @@ } static struct connection_entry * -alloc_connection_entry(struct options *options, const int msglevel) +alloc_connection_entry(struct options *options, const unsigned int msglevel) { struct connection_list *l = alloc_connection_list_if_undef(options); struct connection_entry *e; @@ -2141,7 +2141,7 @@ } static struct remote_entry * -alloc_remote_entry(struct options *options, const int msglevel) +alloc_remote_entry(struct options *options, const unsigned int msglevel) { struct remote_list *l = alloc_remote_list_if_undef(options); struct remote_entry *e; @@ -2698,7 +2698,7 @@ if (!options->tls_server && !options->tls_client) { - int msglevel = M_USAGE; + unsigned int msglevel = M_USAGE; if (options->allow_deprecated_insecure_static_crypto) { msglevel = M_INFO; @@ -4598,7 +4598,7 @@ } static void -options_warning_safe_scan2(const int msglevel, +options_warning_safe_scan2(const unsigned int msglevel, const int delim, const bool report_inconsistent, const char *p1, @@ -4666,7 +4666,7 @@ } static void -options_warning_safe_scan1(const int msglevel, +options_warning_safe_scan1(const unsigned int msglevel, const int delim, const bool report_inconsistent, const struct buffer *b1_src, @@ -4687,7 +4687,7 @@ } static void -options_warning_safe_ml(const int msglevel, char *actual, const char *expected, size_t actual_n) +options_warning_safe_ml(const unsigned int msglevel, char *actual, const char *expected, size_t actual_n) { struct gc_arena gc = gc_new(); @@ -4784,7 +4784,7 @@ */ int -parse_topology(const char *str, const int msglevel) +parse_topology(const char *str, const unsigned int msglevel) { if (streq(str, "net30")) { @@ -4840,7 +4840,7 @@ } bool -auth_retry_set(const int msglevel, const char *option) +auth_retry_set(const unsigned int msglevel, const char *option) { if (streq(option, "interact")) { @@ -5004,7 +5004,7 @@ #if 0 static void -ping_rec_err(int msglevel) +ping_rec_err(unsigned int msglevel) { msg(msglevel, "only one of --ping-exit or --ping-restart options may be specified"); } @@ -5032,7 +5032,7 @@ const int n, const char *file, const int line_num, - int msglevel, + unsigned int msglevel, struct gc_arena *gc) { const int STATE_INITIAL = 0; @@ -5337,7 +5337,7 @@ const char *file, int line, const int level, - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es); @@ -5348,7 +5348,7 @@ int level, const char *top_file, const int top_line, - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) @@ -5421,7 +5421,7 @@ read_config_string(const char *prefix, struct options *options, const char *config, - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) @@ -5454,7 +5454,7 @@ parse_argv(struct options *options, const int argc, char *argv[], - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) @@ -5573,7 +5573,7 @@ char line[OPTION_PARM_SIZE]; int line_num = 0; const char *file = "[PUSH-OPTIONS]"; - const int msglevel = D_PUSH_ERRORS|M_OPTERR; + const unsigned int msglevel = D_PUSH_ERRORS|M_OPTERR; while (buf_parse(buf, ',', line, sizeof(line))) { @@ -5596,7 +5596,7 @@ void options_server_import(struct options *o, const char *filename, - int msglevel, + unsigned int msglevel, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) @@ -5616,7 +5616,7 @@ void options_string_import(struct options *options, const char *config, - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) @@ -5639,7 +5639,7 @@ const unsigned int type, const unsigned int allowed, unsigned int *found, - const int msglevel, + const unsigned int msglevel, struct options *options, bool is_inline) { @@ -5693,7 +5693,7 @@ #define NM_QUOTE_HINT (1<<0) static bool -no_more_than_n_args(const int msglevel, +no_more_than_n_args(const unsigned int msglevel, char *p[], const int max, const unsigned int flags) @@ -5720,8 +5720,8 @@ } } -static inline int -msglevel_forward_compatible(struct options *options, const int msglevel) +static inline unsigned int +msglevel_forward_compatible(struct options *options, const unsigned int msglevel) { return options->forward_compatible ? M_WARN : msglevel; } @@ -5790,14 +5790,14 @@ const char *file, int line, const int level, - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) { struct gc_arena gc = gc_new(); const bool pull_mode = BOOL_CAST(permission_mask & OPT_P_PULL_MODE); - int msglevel_fc = msglevel_forward_compatible(options, msglevel); + unsigned int msglevel_fc = msglevel_forward_compatible(options, msglevel); ASSERT(MAX_PARMS >= 7); @@ -9657,7 +9657,7 @@ else { int i; - int msglevel_unknown = msglevel_fc; + unsigned int msglevel_unknown = msglevel_fc; /* Check if an option is in --ignore-unknown-option and * set warning level to non fatal */ for (i = 0; options->ignore_unknown_option && options->ignore_unknown_option[i]; i++) diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 4ba8e3d..78b0d7c 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -797,7 +797,7 @@ void parse_argv(struct options *options, const int argc, char *argv[], - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es); @@ -872,7 +872,7 @@ void options_server_import(struct options *o, const char *filename, - int msglevel, + unsigned int msglevel, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es); @@ -886,14 +886,14 @@ const int n, const char *file, const int line_num, - int msglevel, + unsigned int msglevel, struct gc_arena *gc); /* * parse/print topology coding */ -int parse_topology(const char *str, const int msglevel); +int parse_topology(const char *str, const unsigned int msglevel); const char *print_topology(const int topology); @@ -907,13 +907,13 @@ int auth_retry_get(void); -bool auth_retry_set(const int msglevel, const char *option); +bool auth_retry_set(const unsigned int msglevel, const char *option); const char *auth_retry_print(void); void options_string_import(struct options *options, const char *config, - const int msglevel, + const unsigned int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es); diff --git a/src/openvpn/options_util.c b/src/openvpn/options_util.c index 80d0c08..cb2a59c 100644 --- a/src/openvpn/options_util.c +++ b/src/openvpn/options_util.c @@ -116,7 +116,7 @@ } int -positive_atoi(const char *str, int msglevel) +positive_atoi(const char *str, unsigned int msglevel) { char *endptr; long long i = strtoll(str, &endptr, 10); @@ -132,7 +132,7 @@ } int -atoi_warn(const char *str, int msglevel) +atoi_warn(const char *str, unsigned int msglevel) { char *endptr; long long i = strtoll(str, &endptr, 10); diff --git a/src/openvpn/options_util.h b/src/openvpn/options_util.h index 2474e7f..2f0b29b 100644 --- a/src/openvpn/options_util.h +++ b/src/openvpn/options_util.h @@ -41,13 +41,13 @@ * integer number. Otherwise print a warning with msglevel and return 0 */ int -positive_atoi(const char *str, int msglevel); +positive_atoi(const char *str, unsigned int msglevel); /** * Converts a str to an integer if the string can be represented as an * integer number. Otherwise print a warning with msglevel and return 0 */ int -atoi_warn(const char *str, int msglevel); +atoi_warn(const char *str, unsigned int msglevel); #endif /* ifndef OPTIONS_UTIL_H_ */ diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c index 76a81c6..057fdbd 100644 --- a/src/openvpn/packet_id.c +++ b/src/openvpn/packet_id.c @@ -54,7 +54,7 @@ #define SEQ_EXPIRED ((time_t)1) #ifdef ENABLE_DEBUG -static void packet_id_debug_print(int msglevel, +static void packet_id_debug_print(unsigned int msglevel, const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, @@ -63,7 +63,7 @@ #endif /* ENABLE_DEBUG */ static inline void -packet_id_debug(int msglevel, +packet_id_debug(unsigned int msglevel, const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, @@ -592,7 +592,7 @@ #ifdef ENABLE_DEBUG static void -packet_id_debug_print(int msglevel, +packet_id_debug_print(unsigned int msglevel, const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c index bafa469..3aafccf 100644 --- a/src/openvpn/plugin.c +++ b/src/openvpn/plugin.c @@ -51,7 +51,7 @@ static struct plugin_common *static_plugin_common = NULL; /* GLOBAL */ static void -plugin_show_string_array(int msglevel, const char *name, const char *array[]) +plugin_show_string_array(unsigned int msglevel, const char *name, const char *array[]) { int i; for (i = 0; array[i]; ++i) @@ -64,7 +64,7 @@ } static void -plugin_show_args_env(int msglevel, const char *argv[], const char *envp[]) +plugin_show_args_env(unsigned int msglevel, const char *argv[], const char *envp[]) { if (check_debug_level(msglevel)) { @@ -186,7 +186,7 @@ #ifndef ENABLE_SMALL void -plugin_option_list_print(const struct plugin_option_list *list, int msglevel) +plugin_option_list_print(const struct plugin_option_list *list, unsigned int msglevel) { int i; struct gc_arena gc = gc_new(); @@ -1024,7 +1024,7 @@ #ifdef ENABLE_DEBUG void -plugin_return_print(const int msglevel, const char *prefix, const struct plugin_return *pr) +plugin_return_print(const unsigned int msglevel, const char *prefix, const struct plugin_return *pr) { int i; msg(msglevel, "PLUGIN_RETURN_PRINT %s", prefix); diff --git a/src/openvpn/plugin.h b/src/openvpn/plugin.h index 5e91c60..003fcbb 100644 --- a/src/openvpn/plugin.h +++ b/src/openvpn/plugin.h @@ -110,7 +110,7 @@ struct gc_arena *gc); #ifndef ENABLE_SMALL -void plugin_option_list_print(const struct plugin_option_list *list, int msglevel); +void plugin_option_list_print(const struct plugin_option_list *list, unsigned int msglevel); #endif @@ -144,7 +144,7 @@ void plugin_return_free(struct plugin_return *pr); #ifdef ENABLE_DEBUG -void plugin_return_print(const int msglevel, const char *prefix, const struct plugin_return *pr); +void plugin_return_print(const unsigned int msglevel, const char *prefix, const struct plugin_return *pr); #endif diff --git a/src/openvpn/pool.c b/src/openvpn/pool.c index ced172c..c144c01 100644 --- a/src/openvpn/pool.c +++ b/src/openvpn/pool.c @@ -118,7 +118,7 @@ * Verify start/end range */ bool -ifconfig_pool_verify_range(const int msglevel, const in_addr_t start, const in_addr_t end) +ifconfig_pool_verify_range(const unsigned int msglevel, const in_addr_t start, const in_addr_t end) { struct gc_arena gc = gc_new(); bool ret = true; @@ -534,7 +534,7 @@ } static void -ifconfig_pool_msg(const struct ifconfig_pool *pool, int msglevel) +ifconfig_pool_msg(const struct ifconfig_pool *pool, unsigned int msglevel) { struct status_output *so = status_open(NULL, 0, msglevel, NULL, 0); ASSERT(so); diff --git a/src/openvpn/pool.h b/src/openvpn/pool.h index 9c3905d..b47cff0 100644 --- a/src/openvpn/pool.h +++ b/src/openvpn/pool.h @@ -79,7 +79,7 @@ void ifconfig_pool_free(struct ifconfig_pool *pool); -bool ifconfig_pool_verify_range(const int msglevel, const in_addr_t start, const in_addr_t end); +bool ifconfig_pool_verify_range(const unsigned int msglevel, const in_addr_t start, const in_addr_t end); ifconfig_pool_handle ifconfig_pool_acquire(struct ifconfig_pool *pool, in_addr_t *local, in_addr_t *remote, struct in6_addr *remote_ipv6, const char *common_name); diff --git a/src/openvpn/push.c b/src/openvpn/push.c index ad8fa3d7..34e5b7a 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -378,7 +378,7 @@ * @return true on success, false on failure. */ static bool push_option_fmt(struct gc_arena *gc, struct push_list *push_list, - int msglevel, const char *fmt, ...) + unsigned int msglevel, const char *fmt, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO __attribute__ ((format(gnu_printf, 4, 5))) @@ -852,7 +852,7 @@ static void push_option_ex(struct gc_arena *gc, struct push_list *push_list, - const char *opt, bool enable, int msglevel) + const char *opt, bool enable, unsigned int msglevel) { if (!string_class(opt, CC_ANY, CC_COMMA)) { @@ -880,7 +880,7 @@ } void -push_option(struct options *o, const char *opt, int msglevel) +push_option(struct options *o, const char *opt, unsigned int msglevel) { push_option_ex(&o->gc, &o->push_list, opt, true, msglevel); } @@ -902,7 +902,7 @@ } void -push_options(struct options *o, char **p, int msglevel, struct gc_arena *gc) +push_options(struct options *o, char **p, unsigned int msglevel, struct gc_arena *gc) { const char **argv = make_extended_arg_array(p, false, gc); char *opt = print_argv(argv, gc, 0); @@ -911,7 +911,7 @@ static bool push_option_fmt(struct gc_arena *gc, struct push_list *push_list, - int msglevel, const char *format, ...) + unsigned int msglevel, const char *format, ...) { va_list arglist; char tmp[256] = {0}; diff --git a/src/openvpn/push.h b/src/openvpn/push.h index 048b4c4..86074d2 100644 --- a/src/openvpn/push.h +++ b/src/openvpn/push.h @@ -58,9 +58,9 @@ void clone_push_list(struct options *o); -void push_option(struct options *o, const char *opt, int msglevel); +void push_option(struct options *o, const char *opt, unsigned int msglevel); -void push_options(struct options *o, char **p, int msglevel, +void push_options(struct options *o, char **p, unsigned int msglevel, struct gc_arena *gc); void push_reset(struct options *o); diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 156262a..2b624ba 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1340,7 +1340,7 @@ } void -print_default_gateway(const int msglevel, +print_default_gateway(const unsigned int msglevel, const struct route_gateway_info *rgi, const struct route_ipv6_gateway_info *rgi6) { @@ -3314,18 +3314,18 @@ * Show current routing table */ void -show_routes(int msglev) +show_routes(unsigned int msglevel) { struct gc_arena gc = gc_new(); const MIB_IPFORWARDTABLE *rt = get_windows_routing_table(&gc); - msg(msglev, "SYSTEM ROUTING TABLE"); + msg(msglevel, "SYSTEM ROUTING TABLE"); if (rt) { for (DWORD i = 0; i < rt->dwNumEntries; ++i) { - msg(msglev, "%s", format_route_entry(&rt->table[i], &gc)); + msg(msglevel, "%s", format_route_entry(&rt->table[i], &gc)); } } gc_free(&gc); diff --git a/src/openvpn/route.h b/src/openvpn/route.h index f015a12..faae424 100644 --- a/src/openvpn/route.h +++ b/src/openvpn/route.h @@ -356,7 +356,7 @@ const struct in6_addr *dest, openvpn_net_ctx_t *ctx); -void print_default_gateway(const int msglevel, +void print_default_gateway(const unsigned int msglevel, const struct route_gateway_info *rgi, const struct route_ipv6_gateway_info *rgi6); @@ -381,7 +381,7 @@ #ifdef _WIN32 -void show_routes(int msglev); +void show_routes(unsigned int msglevel); bool test_routes(const struct route_list *rl, const struct tuntap *tt); diff --git a/src/openvpn/run_command.c b/src/openvpn/run_command.c index 8b5fa4f..a41b05322 100644 --- a/src/openvpn/run_command.c +++ b/src/openvpn/run_command.c @@ -108,7 +108,7 @@ #ifndef WIN32 bool -openvpn_waitpid_check(pid_t pid, const char *msg_prefix, int msglevel) +openvpn_waitpid_check(pid_t pid, const char *msg_prefix, unsigned int msglevel) { if (pid == 0) { diff --git a/src/openvpn/run_command.h b/src/openvpn/run_command.h index e9a6fe1..5570065 100644 --- a/src/openvpn/run_command.h +++ b/src/openvpn/run_command.h @@ -75,7 +75,7 @@ */ bool openvpn_waitpid_check(pid_t pid, const char *msg_prefix, - int msglevel); + unsigned int msglevel); #endif diff --git a/src/openvpn/sig.c b/src/openvpn/sig.c index 9334b10..d8b6954 100644 --- a/src/openvpn/sig.c +++ b/src/openvpn/sig.c @@ -291,7 +291,7 @@ } void -print_signal(const struct signal_info *si, const char *title, int msglevel) +print_signal(const struct signal_info *si, const char *title, unsigned int msglevel) { if (si) { diff --git a/src/openvpn/sig.h b/src/openvpn/sig.h index fe81af9..8c808f6 100644 --- a/src/openvpn/sig.h +++ b/src/openvpn/sig.h @@ -67,7 +67,7 @@ void restore_signal_state(void); -void print_signal(const struct signal_info *si, const char *title, int msglevel); +void print_signal(const struct signal_info *si, const char *title, unsigned int msglevel); void print_status(struct context *c, struct status_output *so); diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 980d8b4..2f31aca 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -81,7 +81,7 @@ get_addr_generic(sa_family_t af, unsigned int flags, const char *hostname, void *network, unsigned int *netbits, int resolve_retry_seconds, struct signal_info *sig_info, - int msglevel) + unsigned int msglevel) { char *endp, *sep, *var_host = NULL; struct addrinfo *ai = NULL; @@ -224,7 +224,7 @@ bool get_ipv6_addr(const char *hostname, struct in6_addr *network, - unsigned int *netbits, int msglevel) + unsigned int *netbits, unsigned int msglevel) { if (get_addr_generic(AF_INET6, GETADDR_RESOLVE, hostname, network, netbits, 0, NULL, msglevel) < 0) @@ -477,7 +477,7 @@ struct addrinfo hints; int status; struct signal_info sigrec = {0}; - int msglevel = (flags & GETADDR_FATAL) ? M_FATAL : D_RESOLVE_ERRORS; + unsigned int msglevel = (flags & GETADDR_FATAL) ? M_FATAL : D_RESOLVE_ERRORS; struct gc_arena gc = gc_new(); const char *print_hostname; const char *print_servname; @@ -541,7 +541,7 @@ int resolve_retries = (flags & GETADDR_TRY_ONCE) ? 1 : ((resolve_retry_seconds + 4)/ fail_wait_interval); const char *fmt; - int level = 0; + unsigned int level = 0; /* this is not a numeric IP, therefore force resolution using the * provided ai_family */ @@ -689,7 +689,7 @@ done: if (sig_info && sig_info->signal_received) { - int level = 0; + unsigned int level = 0; if (flags & GETADDR_FATAL_ON_SIGNAL) { level = M_FATAL; @@ -2059,7 +2059,7 @@ linksock_print_addr(struct link_socket *sock) { struct gc_arena gc = gc_new(); - const int msglevel = (sock->mode == LS_MODE_TCP_ACCEPT_FROM) ? D_INIT_MEDIUM : M_INFO; + const unsigned int msglevel = (sock->mode == LS_MODE_TCP_ACCEPT_FROM) ? D_INIT_MEDIUM : M_INFO; /* print local address */ if (sock->bind_local) diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h index 6d71e83..26a13d6 100644 --- a/src/openvpn/socket.h +++ b/src/openvpn/socket.h @@ -545,7 +545,7 @@ * Translate an IPv6 addr or hostname from string form to in6_addr */ bool get_ipv6_addr(const char *hostname, struct in6_addr *network, - unsigned int *netbits, int msglevel); + unsigned int *netbits, unsigned int msglevel); int openvpn_getaddrinfo(unsigned int flags, const char *hostname, diff --git a/src/openvpn/ssl_verify_backend.h b/src/openvpn/ssl_verify_backend.h index eb80cc8..b4711a5 100644 --- a/src/openvpn/ssl_verify_backend.h +++ b/src/openvpn/ssl_verify_backend.h @@ -195,7 +195,7 @@ * */ void x509_track_add(const struct x509_track **ll_head, const char *name, - int msglevel, struct gc_arena *gc); + unsigned int msglevel, struct gc_arena *gc); /* * Save X509 fields to environment, using the naming convention: diff --git a/src/openvpn/ssl_verify_mbedtls.c b/src/openvpn/ssl_verify_mbedtls.c index 25ad09c..2db7b17 100644 --- a/src/openvpn/ssl_verify_mbedtls.c +++ b/src/openvpn/ssl_verify_mbedtls.c @@ -358,7 +358,7 @@ } void -x509_track_add(const struct x509_track **ll_head, const char *name, int msglevel, struct gc_arena *gc) +x509_track_add(const struct x509_track **ll_head, const char *name, unsigned int msglevel, struct gc_arena *gc) { struct x509_track *xt; ALLOC_OBJ_CLEAR_GC(xt, struct x509_track, gc); diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c index 1546815..57a2570 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -421,7 +421,7 @@ */ void -x509_track_add(const struct x509_track **ll_head, const char *name, int msglevel, struct gc_arena *gc) +x509_track_add(const struct x509_track **ll_head, const char *name, unsigned int msglevel, struct gc_arena *gc) { struct x509_track *xt; ALLOC_OBJ_CLEAR_GC(xt, struct x509_track, gc); diff --git a/src/openvpn/status.c b/src/openvpn/status.c index 4b0e516..06bb916 100644 --- a/src/openvpn/status.c +++ b/src/openvpn/status.c @@ -239,14 +239,13 @@ if (so->msglevel >= 0 && !so->errors) { - msg(so->msglevel, "%s", buf); + msg((unsigned int)so->msglevel, "%s", buf); } if (so->fd >= 0 && !so->errors) { - int len; strcat(buf, "\n"); - len = strlen(buf); + size_t len = strlen(buf); if (len > 0) { if (write(so->fd, buf, len) != len) diff --git a/src/openvpn/status.h b/src/openvpn/status.h index eaed22a..9cd9325 100644 --- a/src/openvpn/status.h +++ b/src/openvpn/status.h @@ -53,6 +53,7 @@ char *filename; int fd; + /* NB: -1 is used to indicate that output should only go to the file */ int msglevel; const struct virtual_output *vout; diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index d15d9eb6..d8c292d 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -108,9 +108,9 @@ const int addr_len, DWORD adapter_index); -static void netsh_command(const struct argv *a, int n, int msglevel); +static void netsh_command(const struct argv *a, int n, unsigned int msglevel); -static void exec_command(const char *prefix, const struct argv *a, int n, int msglevel); +static void exec_command(const char *prefix, const struct argv *a, int n, unsigned int msglevel); static const char *netsh_get_id(const char *dev_node, struct gc_arena *gc); @@ -4201,7 +4201,7 @@ } void -show_tap_win_adapters(int msglev, int warnlev) +show_tap_win_adapters(unsigned int msglevel, unsigned int warnlevel) { struct gc_arena gc = gc_new(); @@ -4218,7 +4218,7 @@ const struct tap_reg *tap_reg = get_tap_reg(&gc); const struct panel_reg *panel_reg = get_panel_reg(&gc); - msg(msglev, "Available adapters [name, GUID, driver]:"); + msg(msglevel, "Available adapters [name, GUID, driver]:"); /* loop through each TAP-Windows adapter registry entry */ for (tr = tap_reg; tr != NULL; tr = tr->next) @@ -4230,7 +4230,7 @@ { if (!strcmp(tr->guid, pr->guid)) { - msg(msglev, "'%s' %s %s", pr->name, tr->guid, print_tun_backend_driver(tr->windows_driver)); + msg(msglevel, "'%s' %s %s", pr->name, tr->guid, print_tun_backend_driver(tr->windows_driver)); ++links; } } @@ -4244,7 +4244,7 @@ /* a TAP adapter exists without a link from the network * connections control panel */ warn_panel_null = true; - msg(msglev, "[NULL] %s", tr->guid); + msg(msglevel, "[NULL] %s", tr->guid); } } @@ -4263,17 +4263,17 @@ /* warn on registry inconsistencies */ if (warn_tap_dup) { - msg(warnlev, "WARNING: Some TAP-Windows adapters have duplicate GUIDs"); + msg(warnlevel, "WARNING: Some TAP-Windows adapters have duplicate GUIDs"); } if (warn_panel_dup) { - msg(warnlev, "WARNING: Some TAP-Windows adapters have duplicate links from the Network Connections control panel"); + msg(warnlevel, "WARNING: Some TAP-Windows adapters have duplicate links from the Network Connections control panel"); } if (warn_panel_null) { - msg(warnlev, "WARNING: Some TAP-Windows adapters have no link from the Network Connections control panel"); + msg(warnlevel, "WARNING: Some TAP-Windows adapters have no link from the Network Connections control panel"); } gc_free(&gc); @@ -5023,31 +5023,31 @@ * Show info for a single adapter */ static void -show_adapter(int msglev, const IP_ADAPTER_INFO *a, struct gc_arena *gc) +show_adapter(unsigned int msglevel, const IP_ADAPTER_INFO *a, struct gc_arena *gc) { - msg(msglev, "%s", a->Description); - msg(msglev, " Index = %d", (int)a->Index); - msg(msglev, " GUID = %s", a->AdapterName); - msg(msglev, " IP = %s", format_ip_addr_string(&a->IpAddressList, gc)); - msg(msglev, " MAC = %s", format_hex_ex(a->Address, a->AddressLength, 0, 1, ":", gc)); - msg(msglev, " GATEWAY = %s", format_ip_addr_string(&a->GatewayList, gc)); + msg(msglevel, "%s", a->Description); + msg(msglevel, " Index = %d", (int)a->Index); + msg(msglevel, " GUID = %s", a->AdapterName); + msg(msglevel, " IP = %s", format_ip_addr_string(&a->IpAddressList, gc)); + msg(msglevel, " MAC = %s", format_hex_ex(a->Address, a->AddressLength, 0, 1, ":", gc)); + msg(msglevel, " GATEWAY = %s", format_ip_addr_string(&a->GatewayList, gc)); if (a->DhcpEnabled) { - msg(msglev, " DHCP SERV = %s", format_ip_addr_string(&a->DhcpServer, gc)); - msg(msglev, " DHCP LEASE OBTAINED = %s", time_string(a->LeaseObtained, 0, false, gc)); - msg(msglev, " DHCP LEASE EXPIRES = %s", time_string(a->LeaseExpires, 0, false, gc)); + msg(msglevel, " DHCP SERV = %s", format_ip_addr_string(&a->DhcpServer, gc)); + msg(msglevel, " DHCP LEASE OBTAINED = %s", time_string(a->LeaseObtained, 0, false, gc)); + msg(msglevel, " DHCP LEASE EXPIRES = %s", time_string(a->LeaseExpires, 0, false, gc)); } if (a->HaveWins) { - msg(msglev, " PRI WINS = %s", format_ip_addr_string(&a->PrimaryWinsServer, gc)); - msg(msglev, " SEC WINS = %s", format_ip_addr_string(&a->SecondaryWinsServer, gc)); + msg(msglevel, " PRI WINS = %s", format_ip_addr_string(&a->PrimaryWinsServer, gc)); + msg(msglevel, " SEC WINS = %s", format_ip_addr_string(&a->SecondaryWinsServer, gc)); } { const IP_PER_ADAPTER_INFO *pai = get_per_adapter_info(a->Index, gc); if (pai) { - msg(msglev, " DNS SERV = %s", format_ip_addr_string(&pai->DnsServerList, gc)); + msg(msglevel, " DNS SERV = %s", format_ip_addr_string(&pai->DnsServerList, gc)); } } } @@ -5056,12 +5056,12 @@ * Show current adapter list */ void -show_adapters(int msglev) +show_adapters(unsigned int msglevel) { struct gc_arena gc = gc_new(); const IP_ADAPTER_INFO *ai = get_adapter_info_list(&gc); - msg(msglev, "SYSTEM ADAPTER LIST"); + msg(msglevel, "SYSTEM ADAPTER LIST"); if (ai) { const IP_ADAPTER_INFO *a; @@ -5069,7 +5069,7 @@ /* find index in the linked list */ for (a = ai; a != NULL; a = a->Next) { - show_adapter(msglev, a, &gc); + show_adapter(msglevel, a, &gc); } } gc_free(&gc); @@ -5286,7 +5286,7 @@ } static void -exec_command(const char *prefix, const struct argv *a, int n, int msglevel) +exec_command(const char *prefix, const struct argv *a, int n, unsigned int msglevel) { int i; for (i = 0; i < n; ++i) @@ -5307,7 +5307,7 @@ } static void -netsh_command(const struct argv *a, int n, int msglevel) +netsh_command(const struct argv *a, int n, unsigned int msglevel) { exec_command("NETSH", a, n, msglevel); } diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 5407e47..77c1d76 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -449,9 +449,9 @@ int *count, in_addr_t *netmask); -void show_tap_win_adapters(int msglev, int warnlev); +void show_tap_win_adapters(unsigned int msglevel, unsigned int warnlevel); -void show_adapters(int msglev); +void show_adapters(unsigned int msglevel); void tap_allow_nonadmin_access(const char *dev_node); diff --git a/tests/unit_tests/openvpn/mock_ssl_dependencies.c b/tests/unit_tests/openvpn/mock_ssl_dependencies.c index 5cfe8d0..c8612ab 100644 --- a/tests/unit_tests/openvpn/mock_ssl_dependencies.c +++ b/tests/unit_tests/openvpn/mock_ssl_dependencies.c @@ -39,7 +39,7 @@ int parse_line(const char *line, char **p, const int n, const char *file, - const int line_num, int msglevel, struct gc_arena *gc) + const int line_num, unsigned int msglevel, struct gc_arena *gc) { /* Dummy function to get the linker happy, should never be called */ assert_true(false); diff --git a/tests/unit_tests/openvpn/test_argv.c b/tests/unit_tests/openvpn/test_argv.c index 33b3dec..eb232dd 100644 --- a/tests/unit_tests/openvpn/test_argv.c +++ b/tests/unit_tests/openvpn/test_argv.c @@ -23,7 +23,7 @@ int __wrap_parse_line(const char *line, char **p, const int n, const char *file, - const int line_num, int msglevel, struct gc_arena *gc) + const int line_num, unsigned int msglevel, struct gc_arena *gc) { p[0] = PATH1 PATH2; p[1] = PARAM1; diff --git a/tests/unit_tests/openvpn/test_misc.c b/tests/unit_tests/openvpn/test_misc.c index 0c604ff..3272f6b 100644 --- a/tests/unit_tests/openvpn/test_misc.c +++ b/tests/unit_tests/openvpn/test_misc.c @@ -335,7 +335,7 @@ assert_false(valid_integer("-2147483653", false)); - int msglevel = D_LOW; + unsigned int msglevel = D_LOW; int saved_log_level = mock_get_debug_level(); mock_set_debug_level(D_LOW); diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/openvpn/test_pkcs11.c index adad40b..052e910 100644 --- a/tests/unit_tests/openvpn/test_pkcs11.c +++ b/tests/unit_tests/openvpn/test_pkcs11.c @@ -60,7 +60,7 @@ /* stubs for some unused functions instead of pulling in too many dependencies */ int parse_line(const char *line, char **p, const int n, const char *file, - const int line_num, int msglevel, struct gc_arena *gc) + const int line_num, unsigned int msglevel, struct gc_arena *gc) { assert_true(0); return 0; diff --git a/tests/unit_tests/openvpn/test_pkt.c b/tests/unit_tests/openvpn/test_pkt.c index ebffabe..5f741f6 100644 --- a/tests/unit_tests/openvpn/test_pkt.c +++ b/tests/unit_tests/openvpn/test_pkt.c @@ -46,7 +46,7 @@ int parse_line(const char *line, char **p, const int n, const char *file, - const int line_num, int msglevel, struct gc_arena *gc) + const int line_num, unsigned int msglevel, struct gc_arena *gc) { /* Dummy function to get the linker happy, should never be called */ assert_true(false); diff --git a/tests/unit_tests/openvpn/test_tls_crypt.c b/tests/unit_tests/openvpn/test_tls_crypt.c index cc415c8..998e10d 100644 --- a/tests/unit_tests/openvpn/test_tls_crypt.c +++ b/tests/unit_tests/openvpn/test_tls_crypt.c @@ -100,7 +100,7 @@ int __wrap_parse_line(const char *line, char **p, const int n, const char *file, - const int line_num, int msglevel, struct gc_arena *gc) + const int line_num, unsigned int msglevel, struct gc_arena *gc) { p[0] = PATH1 PATH2; p[1] = PARAM1; diff --git a/tests/unit_tests/openvpn/test_user_pass.c b/tests/unit_tests/openvpn/test_user_pass.c index 400c0f4..bc9ba54 100644 --- a/tests/unit_tests/openvpn/test_user_pass.c +++ b/tests/unit_tests/openvpn/test_user_pass.c @@ -77,7 +77,7 @@ /* stubs for some unused functions instead of pulling in too many dependencies */ int parse_line(const char *line, char **p, const int n, const char *file, - const int line_num, int msglevel, struct gc_arena *gc) + const int line_num, unsigned int msglevel, struct gc_arena *gc) { assert_true(0); return 0; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1110?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Id492cb774c6d022d06bb3cf5fec2a4bdd410e619 Gerrit-Change-Number: 1110 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld <fr...@li...> Gerrit-Reviewer: plaisthos <arn...@rf...> Gerrit-CC: openvpn-devel <ope...@li...> Gerrit-Attention: plaisthos <arn...@rf...> Gerrit-MessageType: newchange |