From: "flichtenheld (Code Review)" Date: Mon, 15 Sep 2025 12:05:16 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="l2eTwLZuXto="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: Enable -Wsign-conversion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --l2eTwLZuXto= 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/+/1186?usp=3Demail to review the following change. Change subject: Enable -Wsign-conversion ...................................................................... Enable -Wsign-conversion As before with -Wconversion override all the known issues to be able to address them one by one. Change-Id: Iecf502ec811e99c56647b2d45298fa0fb66960fb Signed-off-by: Frank Lichtenheld --- M CMakeLists.txt M configure.ac M src/openvpn/argv.c M src/openvpn/base64.c M src/openvpn/buffer.c M src/openvpn/buffer.h M src/openvpn/clinat.c M src/openvpn/comp-lz4.c M src/openvpn/console_builtin.c M src/openvpn/crypto.c M src/openvpn/crypto_epoch.c M src/openvpn/crypto_mbedtls.c M src/openvpn/crypto_openssl.c M src/openvpn/dhcp.c M src/openvpn/env_set.c M src/openvpn/error.h M src/openvpn/event.c M src/openvpn/fragment.c M src/openvpn/list.h M src/openvpn/lzo.c M src/openvpn/mbuf.c M src/openvpn/networking_sitnl.c M src/openvpn/ntlm.c M src/openvpn/otime.h M src/openvpn/packet_id.c M src/openvpn/platform.h M src/openvpn/plugin.c M src/openvpn/pool.c M src/openvpn/reliable.c M src/openvpn/socket.h M src/openvpn/ssl_util.c M src/openvpn/status.c M src/openvpn/wfp_block.c M src/openvpn/xkey_provider.c M src/openvpnmsica/dllmain.c M src/openvpnserv/common.c M src/openvpnserv/interactive.c M src/tapctl/tap.c M tests/unit_tests/openvpn/mock_get_random.c M tests/unit_tests/openvpn/mock_msg.c M tests/unit_tests/openvpn/test_networking.c 41 files changed, 228 insertions(+), 80 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/86/1186/1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 51f4221..803cdb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ check_and_add_compiler_flag(-Wno-stringop-truncation NoStringOpTruncat= ion) check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes) check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition) - add_compile_options(-Wconversion -Wno-sign-conversion) + add_compile_options(-Wconversion) if (USE_WERROR) add_compile_options(-Werror) endif () diff --git a/configure.ac b/configure.ac index 957205e..b23939e 100644 --- a/configure.ac +++ b/configure.ac @@ -1396,7 +1396,7 @@ ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation]) ACL_CHECK_ADD_COMPILE_FLAGS([-Wstrict-prototypes]) ACL_CHECK_ADD_COMPILE_FLAGS([-Wold-style-definition]) -ACL_CHECK_ADD_COMPILE_FLAGS([-Wconversion -Wno-sign-conversion]) +ACL_CHECK_ADD_COMPILE_FLAGS([-Wconversion]) ACL_CHECK_ADD_COMPILE_FLAGS([-Wall]) if test "${enable_pedantic}" =3D "yes"; then diff --git a/src/openvpn/argv.c b/src/openvpn/argv.c index 55deef5..5d4ca57 100644 --- a/src/openvpn/argv.c +++ b/src/openvpn/argv.c @@ -323,6 +323,11 @@ return f; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + /** * Create a struct argv based on a format string * @@ -418,6 +423,10 @@ return res; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + /** * printf() variant which populates a struct argv. It processes the * format string with the provided arguments. For each space separator f= ound diff --git a/src/openvpn/base64.c b/src/openvpn/base64.c index 2a5a46d..00fef04 100644 --- a/src/openvpn/base64.c +++ b/src/openvpn/base64.c @@ -44,6 +44,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif static char base64_chars[] =3D "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop= qrstuvwxyz0123456789+/"; diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index b6d6669..023f7fe 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -109,6 +109,11 @@ return buf; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + struct buffer #ifdef DMALLOC clone_buf_debug(const struct buffer *buf, const char *file, int line) diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index 1405667..15377e9 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -327,6 +327,11 @@ return true; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static inline void buf_set_write(struct buffer *buf, uint8_t *data, int size) { @@ -851,6 +856,10 @@ return memcmp(BPTR(src), match, size) =3D=3D 0; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + bool buf_string_match_head_str(const struct buffer *src, const char *match= ); bool buf_string_compare_advance(struct buffer *src, const char *match); diff --git a/src/openvpn/clinat.c b/src/openvpn/clinat.c index 2d21daf..fdd1a34 100644 --- a/src/openvpn/clinat.c +++ b/src/openvpn/clinat.c @@ -180,6 +180,11 @@ gc_free(&gc); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + void client_nat_transform(const struct client_nat_option_list *list, struct buf= fer *ipbuf, const int direction) diff --git a/src/openvpn/comp-lz4.c b/src/openvpn/comp-lz4.c index a78c664..87173d6 100644 --- a/src/openvpn/comp-lz4.c +++ b/src/openvpn/comp-lz4.c @@ -91,6 +91,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif static void @@ -118,10 +119,6 @@ *buf =3D *work; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static void lz4_decompress(struct buffer *buf, struct buffer work, struct compress_con= text *compctx, const struct frame *frame) @@ -207,6 +204,10 @@ } } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + const struct compress_alg lz4_alg =3D { "lz4", lz4_compress_init, lz4_comp= ress_uninit, lz4_compress, lz4_decompress }; diff --git a/src/openvpn/console_builtin.c b/src/openvpn/console_builtin.c index 71c0025..61d1657 100644 --- a/src/openvpn/console_builtin.c +++ b/src/openvpn/console_builtin.c @@ -187,6 +187,11 @@ #endif /* HAVE_TERMIOS_H */ +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif /** * Core function for getting input from console @@ -273,11 +278,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** * @copydoc query_user_exec() * diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 8e56881..f033a97 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -62,6 +62,12 @@ * happen unless the frame parameters are wrong. */ +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static void openvpn_encrypt_aead(struct buffer *buf, struct buffer work, struct crypto= _options *opt) { @@ -186,11 +192,6 @@ return; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static void openvpn_encrypt_v1(struct buffer *buf, struct buffer work, struct crypto_o= ptions *opt) { @@ -1537,10 +1538,6 @@ gc_free(&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int write_key_file(const int nkeys, const char *filename) { @@ -1599,6 +1596,10 @@ return nbits; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void must_have_n_keys(const char *filename, const char *option, const struct ke= y2 *key2, int n) { diff --git a/src/openvpn/crypto_epoch.c b/src/openvpn/crypto_epoch.c index 7026ff8..e0654d1 100644 --- a/src/openvpn/crypto_epoch.c +++ b/src/openvpn/crypto_epoch.c @@ -38,6 +38,12 @@ #include "buffer.h" #include "integer.h" +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + void ovpn_hkdf_expand(const uint8_t *secret, const uint8_t *info, int info_len,= uint8_t *out, int out_len) @@ -72,11 +78,6 @@ hmac_ctx_free(hmac_ctx); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - bool ovpn_expand_label(const uint8_t *secret, size_t secret_len, const uint8_t = *label, size_t label_len, const uint8_t *context, size_t context_len, uint8_t *out= , uint16_t out_len) @@ -168,10 +169,6 @@ key->epoch =3D epoch_key->epoch; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static void epoch_init_send_key_ctx(struct crypto_options *co) { diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index 40978d9..7a44416 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -233,6 +233,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif bool @@ -765,10 +766,6 @@ return 1; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * * Generic message digest information functions diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index f1bfd9f..4c13fe4 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -520,6 +520,12 @@ return ret; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + bool crypto_pem_decode(const char *name, struct buffer *dst, const struct buffe= r *src) { @@ -895,11 +901,6 @@ return EVP_CIPHER_CTX_mode(ctx); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - bool cipher_ctx_mode_cbc(const cipher_ctx_t *ctx) { @@ -1003,10 +1004,6 @@ return cipher_ctx_final(ctx, dst, dst_len); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * * Generic message digest information functions @@ -1221,21 +1218,12 @@ HMAC_CTX_reset(ctx); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - int hmac_ctx_size(HMAC_CTX *ctx) { return HMAC_size(ctx); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void hmac_ctx_reset(HMAC_CTX *ctx) { diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 38e8d40..302d6ac 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -75,6 +75,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif static in_addr_t diff --git a/src/openvpn/env_set.c b/src/openvpn/env_set.c index 487a5e2..3de0374 100644 --- a/src/openvpn/env_set.c +++ b/src/openvpn/env_set.c @@ -434,6 +434,11 @@ return (script_security() >=3D SSEC_PW_ENV || !is_password_env_var(str= )); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + /* Make arrays of strings */ const char ** diff --git a/src/openvpn/error.h b/src/openvpn/error.h index 2ad2c5d..6f13f49 100644 --- a/src/openvpn/error.h +++ b/src/openvpn/error.h @@ -406,6 +406,11 @@ return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static inline int openvpn_errno_maybe_crt(bool *crt_error) { diff --git a/src/openvpn/event.c b/src/openvpn/event.c index ca84d19..2f4a6bc 100644 --- a/src/openvpn/event.c +++ b/src/openvpn/event.c @@ -636,6 +636,11 @@ return stat; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static struct event_set * ep_init(int *maxevents, unsigned int flags) { @@ -1112,6 +1117,10 @@ } #endif /* SELECT */ +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + static struct event_set * event_set_init_simple(int *maxevents, unsigned int flags) { diff --git a/src/openvpn/fragment.c b/src/openvpn/fragment.c index 7fc42e5..9f7dcce 100644 --- a/src/openvpn/fragment.c +++ b/src/openvpn/fragment.c @@ -40,6 +40,11 @@ goto error; \ } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static void fragment_list_buf_init(struct fragment_list *list, const struct frame *fra= me) { @@ -129,6 +134,10 @@ f->outgoing_return =3D alloc_buf(BUF_SIZE(frame)); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + /* * Accept an incoming datagram (which may be a fragment) from remote. * If the datagram is whole (i.e not a fragment), pass through. diff --git a/src/openvpn/list.h b/src/openvpn/list.h index fb3302d..bdb7e41 100644 --- a/src/openvpn/list.h +++ b/src/openvpn/list.h @@ -121,6 +121,11 @@ return hash->n_buckets; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static inline struct hash_bucket * hash_bucket(struct hash *hash, uint32_t hv) { diff --git a/src/openvpn/lzo.c b/src/openvpn/lzo.c index 8daaec0..087de9d 100644 --- a/src/openvpn/lzo.c +++ b/src/openvpn/lzo.c @@ -40,6 +40,12 @@ #include "memdbg.h" +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static void lzo_compress_init(struct compress_context *compctx) { @@ -72,11 +78,6 @@ *header =3D NO_COMPRESS_BYTE; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static void lzo_decompress(struct buffer *buf, struct buffer work, struct compress_con= text *compctx, const struct frame *frame) diff --git a/src/openvpn/mbuf.c b/src/openvpn/mbuf.c index 448124c..dc6b42f 100644 --- a/src/openvpn/mbuf.c +++ b/src/openvpn/mbuf.c @@ -37,6 +37,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif struct mbuf_set * @@ -49,10 +50,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void mbuf_free(struct mbuf_set *ms) { diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index 168401f..c08ea7a 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -133,6 +133,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif /** diff --git a/src/openvpn/ntlm.c b/src/openvpn/ntlm.c index 521677b..4ea8133 100644 --- a/src/openvpn/ntlm.c +++ b/src/openvpn/ntlm.c @@ -77,6 +77,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif static void diff --git a/src/openvpn/otime.h b/src/openvpn/otime.h index 108d0f2..f9cc64e 100644 --- a/src/openvpn/otime.h +++ b/src/openvpn/otime.h @@ -62,6 +62,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif static inline int diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c index 63a4cae..e25bd40 100644 --- a/src/openvpn/packet_id.c +++ b/src/openvpn/packet_id.c @@ -74,6 +74,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif static void diff --git a/src/openvpn/platform.h b/src/openvpn/platform.h index f1a2b01..17479f1 100644 --- a/src/openvpn/platform.h +++ b/src/openvpn/platform.h @@ -93,6 +93,11 @@ * Extract UID or GID */ +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static inline int platform_state_user_uid(const struct platform_state_user *s) { @@ -111,6 +116,10 @@ return -1; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void platform_chroot(const char *path); void platform_nice(int niceval); diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c index 769fe65..66626c0 100644 --- a/src/openvpn/plugin.c +++ b/src/openvpn/plugin.c @@ -455,6 +455,11 @@ #define _OPENVPN_PATCH_LEVEL "git:" CONFIGURE_GIT_REVISION CONFIGURE_GIT_F= LAGS #endif +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static void plugin_open_item(struct plugin *p, const struct plugin_option *o, struct openvpn_plugin_string_list **retlist, const char *= *envp, @@ -537,6 +542,10 @@ } } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + static int plugin_call_item(const struct plugin *p, void *per_client_context, const i= nt type, const struct argv *av, struct openvpn_plugin_string_list = **retlist, diff --git a/src/openvpn/pool.c b/src/openvpn/pool.c index 0e95c5e..ee3ea5a 100644 --- a/src/openvpn/pool.c +++ b/src/openvpn/pool.c @@ -136,6 +136,11 @@ return ret; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + struct ifconfig_pool * ifconfig_pool_init(const bool ipv4_pool, enum pool_type type, in_addr_t st= art, in_addr_t end, const bool duplicate_cn, const bool ipv6_pool, const st= ruct in6_addr ipv6_base, @@ -708,6 +713,10 @@ } } =20 +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void ifconfig_pool_write(struct ifconfig_pool_persist *persist, const struct if= config_pool *pool) { diff --git a/src/openvpn/reliable.c b/src/openvpn/reliable.c index 0c8b552..26be1d9 100644 --- a/src/openvpn/reliable.c +++ b/src/openvpn/reliable.c @@ -344,6 +344,12 @@ * struct reliable member functions. */ +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + void reliable_init(struct reliable *rel, int buf_size, int offset, int array_si= ze, bool hold) { @@ -687,11 +693,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /* in how many seconds should we wake up to check for timeout */ /* if we return BIG_TIMEOUT, nothing to wait for */ interval_t diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h index cce9183..466af7e 100644 --- a/src/openvpn/socket.h +++ b/src/openvpn/socket.h @@ -638,6 +638,11 @@ struct link_socket_actual *to); +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static inline ssize_t link_socket_write_udp_posix(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to) @@ -660,6 +665,10 @@ return send(sock->sd, BPTR(buf), BLEN(buf), MSG_NOSIGNAL); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + #endif /* ifdef _WIN32 */ static inline ssize_t diff --git a/src/openvpn/ssl_util.c b/src/openvpn/ssl_util.c index 50e8c03..10970e8 100644 --- a/src/openvpn/ssl_util.c +++ b/src/openvpn/ssl_util.c @@ -56,6 +56,12 @@ return var_value; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + unsigned int extract_iv_proto(const char *peer_info) { @@ -290,11 +296,6 @@ return NULL; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - int get_num_elements(const char *string, char delimiter) { diff --git a/src/openvpn/status.c b/src/openvpn/status.c index a9f9498..d3f30b39 100644 --- a/src/openvpn/status.c +++ b/src/openvpn/status.c @@ -210,6 +210,7 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #endif #define STATUS_PRINTF_MAXLEN 512 diff --git a/src/openvpn/wfp_block.c b/src/openvpn/wfp_block.c index 506d41b..669031a 100644 --- a/src/openvpn/wfp_block.c +++ b/src/openvpn/wfp_block.c @@ -131,6 +131,11 @@ return err; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + /* * Block outgoing local traffic, possibly DNS only, except for * (i) adapter with the specified index (and loopback, if all is blocked) @@ -340,6 +345,10 @@ return err; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + DWORD delete_wfp_block_filters(HANDLE engine_handle) { diff --git a/src/openvpn/xkey_provider.c b/src/openvpn/xkey_provider.c index 1819ab0..8dfbc1a 100644 --- a/src/openvpn/xkey_provider.c +++ b/src/openvpn/xkey_provider.c @@ -940,6 +940,11 @@ return ret; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static int signature_sign(void *ctx, unsigned char *sig, size_t *siglen, size_t sigsi= ze, const unsigned char *tbs, size_t tbslen) @@ -1074,6 +1079,10 @@ return signature_sign(ctx, sig, siglen, sigsize, buf, sz); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + /* Sign digest using native sign function -- will only work for native keys */ int diff --git a/src/openvpnmsica/dllmain.c b/src/openvpnmsica/dllmain.c index e7d4a4b..e57285d 100644 --- a/src/openvpnmsica/dllmain.c +++ b/src/openvpnmsica/dllmain.c @@ -98,6 +98,10 @@ return true; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif void x_msg_va(const unsigned int flags, const char *format, va_list arglist) diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c index a42c65d..38b6de6 100644 --- a/src/openvpnserv/common.c +++ b/src/openvpnserv/common.c @@ -26,6 +26,11 @@ LPCWSTR service_instance =3D L""; static wchar_t win_sys_path[MAX_PATH]; +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static DWORD GetRegString(HKEY key, LPCWSTR value, LPWSTR data, DWORD size, LPCWSTR def= ault_value) { @@ -52,7 +57,6 @@ return ERROR_SUCCESS; } - DWORD GetOpenvpnSettings(settings_t *s) { @@ -274,6 +278,10 @@ return utf16; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + const wchar_t * get_win_sys_path(void) { diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index ce0d4dd..1bddd24 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -512,6 +512,11 @@ free(sud->directory); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif static SOCKADDR_INET sockaddr_inet(short family, inet_address_t *addr) @@ -1383,11 +1388,6 @@ return TRUE; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** * Prepare DNS domain "SearchList" registry value, so additional * VPN domains can be added and its original state can be restored @@ -2619,10 +2619,6 @@ return err; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /** * Return the registry key where NRPT rules are stored * @@ -3561,6 +3557,9 @@ return 0; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif static DWORD WINAPI ServiceCtrlInteractive(DWORD ctrl_code, DWORD event, LPVOID data, LPVOID c= tx) diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c index b633e77..fb19118 100644 --- a/src/tapctl/tap.c +++ b/src/tapctl/tap.c @@ -100,6 +100,11 @@ return fptr; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + /** * Returns length of string of strings * diff --git a/tests/unit_tests/openvpn/mock_get_random.c b/tests/unit_tests/= openvpn/mock_get_random.c index 77db18e..58ca5f0 100644 --- a/tests/unit_tests/openvpn/mock_get_random.c +++ b/tests/unit_tests/openvpn/mock_get_random.c @@ -28,6 +28,11 @@ #include #include +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + unsigned long get_random(void) { @@ -35,6 +40,10 @@ return rand(); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void prng_bytes(uint8_t *output, int len) { diff --git a/tests/unit_tests/openvpn/mock_msg.c b/tests/unit_tests/openvpn= /mock_msg.c index 603520b..38e036e 100644 --- a/tests/unit_tests/openvpn/mock_msg.c +++ b/tests/unit_tests/openvpn/mock_msg.c @@ -45,6 +45,10 @@ char mock_msg_buf[MOCK_MSG_BUF]; +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif void mock_set_debug_level(int level) @@ -70,6 +74,10 @@ return x_debug_level; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void x_msg_va(const unsigned int flags, const char *format, va_list arglist) { diff --git a/tests/unit_tests/openvpn/test_networking.c b/tests/unit_tests/= openvpn/test_networking.c index f2da83e..4bda473 100644 --- a/tests/unit_tests/openvpn/test_networking.c +++ b/tests/unit_tests/openvpn/test_networking.c @@ -39,6 +39,11 @@ return net_iface_del(NULL, name); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + static int net__iface_mtu_set(int mtu) { @@ -47,6 +52,10 @@ return net_iface_mtu_set(NULL, iface, mtu); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + static int net__addr_v4_add(const char *addr_str, int prefixlen) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1186?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: Iecf502ec811e99c56647b2d45298fa0fb66960fb Gerrit-Change-Number: 1186 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --l2eTwLZuXto= 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

Enable -Wsign-conversion

As before with -Wconversion = override all the known issues
to be able to address them one by one.
=
Change-Id: Iecf502ec811e99c56647b2d45298fa0fb66960fb
Signed-off-by: = Frank Lichtenheld <frank@...2641...>
---
M CMakeLists.txt
M = configure.ac
M src/openvpn/argv.c
M src/openvpn/base64.c
M src/ope= nvpn/buffer.c
M src/openvpn/buffer.h
M src/openvpn/clinat.c
M src/= openvpn/comp-lz4.c
M src/openvpn/console_builtin.c
M src/openvpn/cryp= to.c
M src/openvpn/crypto_epoch.c
M src/openvpn/crypto_mbedtls.c
M= src/openvpn/crypto_openssl.c
M src/openvpn/dhcp.c
M src/openvpn/env_= set.c
M src/openvpn/error.h
M src/openvpn/event.c
M src/openvpn/fr= agment.c
M src/openvpn/list.h
M src/openvpn/lzo.c
M src/openvpn/mb= uf.c
M src/openvpn/networking_sitnl.c
M src/openvpn/ntlm.c
M src/o= penvpn/otime.h
M src/openvpn/packet_id.c
M src/openvpn/platform.h
= M src/openvpn/plugin.c
M src/openvpn/pool.c
M src/openvpn/reliable.c<= br>M src/openvpn/socket.h
M src/openvpn/ssl_util.c
M src/openvpn/stat= us.c
M src/openvpn/wfp_block.c
M src/openvpn/xkey_provider.c
M src= /openvpnmsica/dllmain.c
M src/openvpnserv/common.c
M src/openvpnserv/= interactive.c
M src/tapctl/tap.c
M tests/unit_tests/openvpn/mock_get_= random.c
M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/ope= nvpn/test_networking.c
41 files changed, 228 insertions(+), 80 deletions= (-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/=
86/1186/1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51f4221..803cdb4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,7 +113,7 @@=
check_and_add_compiler_flag(-Wno-stringop-truncation NoStrin= gOpTruncation)
check_and_add_compiler_flag(-Wstrict-pr= ototypes StrictPrototypes)
check_and_add_compiler_flag= (-Wold-style-definition OldStyleDefinition)
- add_compile_options(-Wconversion -Wno-sign-conver= sion)
+ add_compil= e_options(-Wconversion)
if (USE_WERROR)
add_compile_options(-Werror)

endif ()
diff --git a/configure.ac b/configure.ac
index 9= 57205e..b23939e 100644
--- a/configure.ac
+= ++ b/configure.ac
@@ -1396,7 +1396,7 @@
AC= L_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation])
ACL_= CHECK_ADD_COMPILE_FLAGS([-Wstrict-prototypes])
ACL_CHECK_A= DD_COMPILE_FLAGS([-Wold-style-definition])
-ACL_CHECK_ADD_COMPILE_FLAGS([-Wconversion -Wno-sign-co= nversion])
+ACL_CHECK= _ADD_COMPILE_FLAGS([-Wconversion])
ACL_CHECK_ADD_COMPILE_F= LAGS([-Wall])

if test "${enable_ped= antic}" =3D "yes"; then
diff --git a/src/ope= nvpn/argv.c b/src/openvpn/argv.c
index 55deef5..5d4ca57 100= 644
--- a/src/openvpn/argv.c
+++ b/src/open= vpn/argv.c
@@ -323,6 +323,11 @@
return= f;
}

+#if defined(__GNUC__) || defined(__clang__)
= +#pragma GCC diagnostic push

+#pragma GCC diagnostic= ignored "-Wsign-conversion"
+#endif
+
/**
* Create a struct argv based= on a format string
*
@@ -418,6 +423,10 @= @
return res;
}

+#if defined(__GNUC__) |= | defined(__clang__)
= +#pragma GCC diagnostic pop
+#endif
+
/**
* printf() variant which populates a st= ruct argv. It processes the
* format string with the pr= ovided arguments. For each space separator found
diff --gi= t a/src/openvpn/base64.c b/src/openvpn/base64.c
index 2a5a4= 6d..00fef04 100644
--- a/src/openvpn/base64.c
+++ b/src/openvpn/base64.c

@@ -44,6 +44,7 @@
<= span> #if defined(__GNUC__) || defined(__clang__)

#pragma = GCC diagnostic push
#pragma GCC diagnostic ignored "-= Wconversion"
+#p= ragma GCC diagnostic ignored "-Wsign-conversion"
= #endif

static char base64_chars[] =3D &= quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"= ;
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c<= /span>
index b6d6669..023f7fe 100644
--- a/src/ope= nvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@= -109,6 +109,11 @@
return buf;
}

+#if de= fined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conve= rsion"
+#endif
+
str= uct buffer
#ifdef DMALLOC
clone_buf_debug= (const struct buffer *buf, const char *file, int line)
diff= --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h
index = 1405667..15377e9 100644
--- a/src/openvpn/buffer.h+++ b/src/openvpn/buffer.h
@@ -327,6 +327,11 @@
return true;
}
<= br>+#if defined(__GNUC__) || de= fined(__clang__)
+#pr= agma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"+#endif
+
static inline void
buf_set_write(struct buffer *buf, uint8_t *data, int size)
{
@@ -851,6 +856,10 @@
r= eturn memcmp(BPTR(src), match, size) =3D=3D 0;
}
+#if defined= (__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
bool buf_string_match_head_str(const struct buffer= *src, const char *match);

bool buf_stri= ng_compare_advance(struct buffer *src, const char *match);
= diff --git a/src/openvpn/clinat.c b/src/openvpn/clinat.c
in= dex 2d21daf..fdd1a34 100644
--- a/src/openvpn/clinat.c
+++ b/src/openvpn/clinat.c
@@ -180,6 +180,11 @@=
gc_free(&gc);
}
=
+#if defined(__GNUC= __) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"<= /span>
+#endif
+

void
= client_nat_transform(const struct client_nat_option_list *list, stru= ct buffer *ipbuf,
const int direction= )
diff --git a/src/openvpn/comp-lz4.c b/src/openvpn/comp-lz= 4.c
index a78c664..87173d6 100644
--- a/src= /openvpn/comp-lz4.c
+++ b/src/openvpn/comp-lz4.c
= @@ -91,6 +91,7 @@
#if defined(__GNUC__) || defined(_= _clang__)
#pragma GCC diagnostic push
#pr= agma GCC diagnostic ignored "-Wconversion"
+#pragma GCC diagnostic ignored "-Wsi= gn-conversion"
#endif

static void

@@ -118,10 +119,6 @@
*= buf =3D *work;
}

-#if defined(__GNUC__) || defined(__clang__)=
-#pragma GCC diagnosti= c pop
-#endif-
static void
lz4_decompress(struct buffer *buf, struct buffer work, stru= ct compress_context *compctx,
const struct = frame *frame)
@@ -207,6 +204,10 @@
}
}

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
const struct compress_a= lg lz4_alg =3D { "lz4", lz4_compress_init, lz4_compress_uninit, l= z4_compress,
lz4_dec= ompress };

diff --git a/src/openvpn/conso= le_builtin.c b/src/openvpn/console_builtin.c
index 71c0025.= .61d1657 100644
--- a/src/openvpn/console_builtin.c<= br>+++ b/src/openvpn/console_builtin.c
@@ -187,6 +187= ,11 @@

#endif /* HAVE_TERMIOS_H */

+#if def= ined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion&= quot;
+#pragma GCC di= agnostic ignored "-Wsign-conversion"
+#endif

/**
* Core function for getting input from console
<= span>@@ -273,11 +278,6 @@

return ret;
= }

-#= if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversio= n"
-#endif<= br>-
/**<= br> * @copydoc query_user_exec()
*
diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c

i= ndex 8e56881..f033a97 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/crypto.c
@@ -62,6 +62,12 @@<= /span>
* happen unless the frame parameters are wrong. */

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored &q= uot;-Wconversion"

+#endif
+
static void
openvpn_encrypt_aead(struct buffer *buf, struct buffer work, struct cryp= to_options *opt)

{
@@ -186,11 +192,6 @@
return;
}

<= span style=3D"color: hsl(0, 100%, 40%);">-#if defined(__GNUC__) || defined(= __clang__)

-#pragma GCC= diagnostic push
-#prag= ma GCC diagnostic ignored "-Wconversion"
-#endif
-
static void
openvpn_encryp= t_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt)
{
@@ -1537,10 +1538,6 @@
= gc_free(&gc);
}

-#if defined(__GNUC__) || defined(__clang= __)
-#pragma GCC diagno= stic pop
-#endif=
-
int=
write_key_file(const int nkeys, const char *filename)
= {
@@ -1599,6 +1596,10 @@
return= nbits;
}

+#if defined(__GNUC__) || defined(__clang__)=
+#pragma GCC diagnostic pop=
+#endif
+

void must_have_n_keys(const char *filename, const char *option, const st= ruct key2 *key2, int n)
{
diff --git a/src= /openvpn/crypto_epoch.c b/src/openvpn/crypto_epoch.c
index = 7026ff8..e0654d1 100644
--- a/src/openvpn/crypto_epoch.c
+++ b/src/openvpn/crypto_epoch.c
@@ -38,6 +38= ,12 @@
#include "buffer.h"
#inc= lude "integer.h"

+#if defined(__GNUC__) || defined(__clang__)=
+#pragma GCC diagnostic pus= h
+#pragma GCC diagno= stic ignored "-Wconversion"
+#pragma GCC diagnostic ignored "-Wsign-conversion&qu= ot;
+#endif+
void=
ovpn_hkdf_expand(const uint8_t *secret, const uint8_t *info, int= info_len, uint8_t *out,
int out_len)
@@ -72,11 +78,6 @@
hmac_ctx_free(hmac_ctx= );
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
<= br>-#pragma GCC diagnostic ignore= d "-Wconversion"
-#endif
- bool
ovpn_expand_label(const uint8_t *secret, size= _t secret_len, const uint8_t *label, size_t label_len,
= const uint8_t *context, size_t context_len, uint8_t *out, ui= nt16_t out_len)
@@ -168,10 +169,6 @@
k= ey->epoch =3D epoch_key->epoch;
}
<= /span>
-#if defined(__GNUC__) = || defined(__clang__)
-= #pragma GCC diagnostic pop
-#endif
- static void
epoch_init_send_key_ctx(struct crypto_= options *co)
{
diff --git a/src/openvpn/cr= ypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c
index 40978d9= ..7a44416 100644
--- a/src/openvpn/crypto_mbedtls.c<= br>+++ b/src/openvpn/crypto_mbedtls.c
@@ -233,6 +233,= 7 @@
#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push
#pragma GCC diagnostic= ignored "-Wconversion"
+#pragma GCC diagnostic ignored "-Wsign-conversion"<= /span>
#endif

bool
<= span>@@ -765,10 +766,6 @@

return 1;
}=

-#if= defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
/*
*
* Gener= ic message digest information functions
diff --git a/src/op= envpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c
index= f1bfd9f..4c13fe4 100644
--- a/src/openvpn/crypto_openssl.c=
+++ b/src/openvpn/crypto_openssl.c
@@ -520= ,6 +520,12 @@
return ret;
}
+#if defined= (__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"= ;
+#pragma GCC diagno= stic ignored "-Wsign-conversion"
+#endif
+
bool
crypto_pem_decode(const c= har *name, struct buffer *dst, const struct buffer *src)
{=
@@ -895,11 +901,6 @@
return EVP_CIPHE= R_CTX_mode(ctx);
}

-#if defined(__GNUC__) || defined(__clang__)=
-#pragma GCC diagnosti= c push
-#pragma GCC dia= gnostic ignored "-Wconversion"
-#endif
-
bool
cipher_ctx_mode_cbc(const ciphe= r_ctx_t *ctx)
{
@@ -1003,10 +1004,6 @@
return cipher_ctx_final(ctx, dst, dst_len);
}


-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
/*
*
* = Generic message digest information functions
@@ -1221,21 +1= 218,12 @@
HMAC_CTX_reset(ctx);
}

-#if defi= ned(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"=
-#endif
-

int
hmac_ctx_size(HMAC_CTX *ctx)

{
ret= urn HMAC_size(ctx);
}

-#if defined(__GNUC__) || defined(__clang= __)
-#pragma GCC diagno= stic pop
-#endif=
-
void
hmac_ctx_reset(HMAC_CTX *ctx)
{
diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c

inde= x 38e8d40..302d6ac 100644
--- a/src/openvpn/dhcp.c+++ b/src/openvpn/dhcp.c
@@ -75,6 +75,7 @@ #if defined(__GNUC__) || defined(__clang__)
#prag= ma GCC diagnostic push
#pragma GCC diagnostic ignored &quo= t;-Wconversion"
= +#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif


static in_addr_t
diff --git a/src/openvpn/env_set.c b/src/openvpn/env_set.c

index 487a5e2..3de0374 100644

--- a/src/openvpn/env_set= .c
+++ b/src/openvpn/env_set.c
@@ -434,6 +4= 34,11 @@
return (script_security() >=3D SSEC_PW_ENV= || !is_password_env_var(str));
}
=
+#if defined(__GNUC__) || d= efined(__clang__)
+#p= ragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"+#endif
+
/* Make arrays of strin= gs */

const char **
diff= --git a/src/openvpn/error.h b/src/openvpn/error.h
index 2a= d2c5d..6f13f49 100644
--- a/src/openvpn/error.h
<= span>+++ b/src/openvpn/error.h

@@ -406,6 +406,11 @@<= br> return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err= ;
}

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic i= gnored "-Wsign-conversion"
+#endif
+
static inline int
openvpn_errno_mayb= e_crt(bool *crt_error)
{
diff --git a/src/= openvpn/event.c b/src/openvpn/event.c
index ca84d19..2f4a6b= c 100644
--- a/src/openvpn/event.c
+++ b/sr= c/openvpn/event.c
@@ -636,6 +636,11 @@
= return stat;
}

+#if defined(__GNUC__) || defined(__clang__)<= /span>
+#pragma GCC diagnost= ic push
+#pragma GCC = diagnostic ignored "-Wsign-conversion"
+#endif
+
static struct event_set *
ep_init(int *maxevents, unsigned int flags)

{
= @@ -1112,6 +1117,10 @@
}
#endif /* = SELECT */

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif

+
static struct event_set *
event_set_init_simple(int *maxevents, unsigned int flags)
{
diff --git a/src/openvpn/fragment.c b/src/o= penvpn/fragment.c
index 7fc42e5..9f7dcce 100644
<= span>--- a/src/openvpn/fragment.c

+++ b/src/openvpn/fragmen= t.c
@@ -40,6 +40,11 @@
goto error;= \
}

+#if defined(__GNUC__) || defined(__clang__)<= br>+#pragma GCC diagnostic push=
+#pragma GCC diagnos= tic ignored "-Wsign-conversion"
+#endif
+
static void
fragment_list_buf_i= nit(struct fragment_list *list, const struct frame *frame)
= {
@@ -129,6 +134,10 @@
f->outgoing= _return =3D alloc_buf(BUF_SIZE(frame));
}
=
+#if defined(__GNUC= __) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+=
/*
* Accept an incoming datagram (which= may be a fragment) from remote.
* If the datagram is who= le (i.e not a fragment), pass through.
diff --git a/src/ope= nvpn/list.h b/src/openvpn/list.h
index fb3302d..bdb7e41 100= 644
--- a/src/openvpn/list.h
+++ b/src/open= vpn/list.h
@@ -121,6 +121,11 @@
return= hash->n_buckets;
}

+#if defined(__GNUC__) || defined(__cl= ang__)
+#pragma GCC d= iagnostic push
+#prag= ma GCC diagnostic ignored "-Wsign-conversion"
+#endif
+
static inline struct hash_bucket *=
hash_bucket(struct hash *hash, uint32_t hv)
{

diff --git a/src/openvpn/lzo.c b/src/openvpn/lzo.c
index 8daaec0..087de9d 100644
--- a/src/openv= pn/lzo.c
+++ b/src/openvpn/lzo.c
@@ -40,6 += 40,12 @@
#include "memdbg.h"


+#if= defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconvers= ion"
+#pragma GC= C diagnostic ignored "-Wsign-conversion"
+#endif
+
static void
lzo_compre= ss_init(struct compress_context *compctx)
{
@@ -72,11 +78,6 @@

*header =3D NO_COMPRESS_BYTE;
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored &quo= t;-Wconversion"

-#= endif
-
static void

lzo_decompress(struct buffer *buf, struct bu= ffer work, struct compress_context *compctx,
= const struct frame *frame)
diff --git a/src/openvpn/mbuf.= c b/src/openvpn/mbuf.c
index 448124c..dc6b42f 100644=
--- a/src/openvpn/mbuf.c
+++ b/src/openvpn/mbuf.c=
@@ -37,6 +37,7 @@
#if defined(__GNUC__) |= | defined(__clang__)
#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion"
<= span style=3D"color: hsl(120, 100%, 40%);">+#pragma GCC diagnostic ignored = "-Wsign-conversion"

#endif

struct mbuf_set *
@@ -49,10 +50,6 @@ return ret;
}

-#if defined(__GNUC__) || defined(__= clang__)

-#pragma GCC d= iagnostic pop
-#endif
-
void<= /span>
mbuf_free(struct mbuf_set *ms)
{diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networkin= g_sitnl.c
index 168401f..c08ea7a 100644
---= a/src/openvpn/networking_sitnl.c
+++ b/src/openvpn/network= ing_sitnl.c
@@ -133,6 +133,7 @@
#if define= d(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic p= ush
#pragma GCC diagnostic ignored "-Wconversion"= ;
+#pragma GCC diagno= stic ignored "-Wsign-conversion"
#endif
/**
diff --git a/src/openvpn/ntl= m.c b/src/openvpn/ntlm.c
index 521677b..4ea8133 100644
--- a/src/openvpn/ntlm.c
+++ b/src/openvpn/ntlm= .c
@@ -77,6 +77,7 @@
#if defined(__GNUC__)= || defined(__clang__)
#pragma GCC diagnostic push<= br> #pragma GCC diagnostic ignored "-Wconversion"+#pragma GCC diagnostic ignore= d "-Wsign-conversion"
#endif

static void
diff --git a/src/openvpn/otime.= h b/src/openvpn/otime.h
index 108d0f2..f9cc64e 100644
--- a/src/openvpn/otime.h
+++ b/src/openvpn/otim= e.h
@@ -62,6 +62,7 @@
#if defined(__GNUC__= ) || defined(__clang__)
#pragma GCC diagnostic push=
#pragma GCC diagnostic ignored "-Wconversion"+#pragma GCC diagnostic ignor= ed "-Wsign-conversion"
#endif
<= /span>
static inline int
diff --git a/src/openvpn= /packet_id.c b/src/openvpn/packet_id.c
index 63a4cae..e25bd= 40 100644
--- a/src/openvpn/packet_id.c
+++= b/src/openvpn/packet_id.c
@@ -74,6 +74,7 @@
#if defined(__GNUC__) || defined(__clang__)

#pragma GCC= diagnostic push
#pragma GCC diagnostic ignored "-Wco= nversion"
+#prag= ma GCC diagnostic ignored "-Wsign-conversion"
#e= ndif

static void
diff --= git a/src/openvpn/platform.h b/src/openvpn/platform.h
index= f1a2b01..17479f1 100644
--- a/src/openvpn/platform.h
+++ b/src/openvpn/platform.h
@@ -93,6 +93,11 @@<= /span>
* Extract UID or GID
*/

+#if defined(__GNU= C__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"=
+#endif
+

static inline = int
platform_state_user_uid(const struct platform_state_us= er *s)
{
@@ -111,6 +116,10 @@
return -1;

}

+#if defined(__GNUC__) || defined(__cla= ng__)
+#pragma GCC di= agnostic pop
+#endif<= /span>
+
vo= id platform_chroot(const char *path);

vo= id platform_nice(int niceval);
diff --git a/src/openvpn/plu= gin.c b/src/openvpn/plugin.c
index 769fe65..66626c0 100644<= /span>
--- a/src/openvpn/plugin.c
+++ b/src/openvp= n/plugin.c
@@ -455,6 +455,11 @@
#define _O= PENVPN_PATCH_LEVEL "git:" CONFIGURE_GIT_REVISION CONFIGURE_GIT_FL= AGS
#endif

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pu= sh
+#pragma GCC diagn= ostic ignored "-Wsign-conversion"
+#endif
+
static void
plugin_open_item(= struct plugin *p, const struct plugin_option *o,
= struct openvpn_plugin_string_list **retlist, const char **envp,
@@ -537,6 +542,10 @@
}
}=

+#= if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
static int
plugin_call_= item(const struct plugin *p, void *per_client_context, const int type,
const struct argv *av, struct openvpn_plugin_= string_list **retlist,
diff --git a/src/openvpn/pool.c b/sr= c/openvpn/pool.c
index 0e95c5e..ee3ea5a 100644
--- a/src/openvpn/pool.c

+++ b/src/openvpn/pool.c
@@ -136,6 +136,11 @@
return ret;
= }

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "= ;-Wsign-conversion"
+#endif
+<= br> struct ifconfig_pool *
ifconfig_pool_init(const = bool ipv4_pool, enum pool_type type, in_addr_t start, in_addr_t end,=
const bool duplicate_cn, const bool ipv6_pool= , const struct in6_addr ipv6_base,
@@ -708,6 +713,10 @@
}
}

+#if defined(__GNUC__) || defined(__cla= ng__)
+#pragma GCC di= agnostic pop
+#endif<= /span>
+
vo= id
ifconfig_pool_write(struct ifconfig_pool_persist *persi= st, const struct ifconfig_pool *pool)
{
di= ff --git a/src/openvpn/reliable.c b/src/openvpn/reliable.c
= index 0c8b552..26be1d9 100644
--- a/src/openvpn/reliable.c<= /span>
+++ b/src/openvpn/reliable.c
@@ -344,6 +344= ,12 @@
* struct reliable member functions.
*/


+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-= Wconversion"
+#p= ragma GCC diagnostic ignored "-Wsign-conversion"
+#endif
+
void
reliable_= init(struct reliable *rel, int buf_size, int offset, int array_size, bool h= old)
{
@@ -687,11 +693,6 @@
}

}

-#if defined(__GNUC__) || defined(__clang__)<= br>-#pragma GCC diagnostic push
-#pragma GCC diagnostic = ignored "-Wconversion"
-#endif
-
/* in how many seconds should we wake up to check for timeout= */
/* if we return BIG_TIMEOUT, nothing to wait for */
interval_t
diff --git a/src/openvpn/socket.h= b/src/openvpn/socket.h
index cce9183..466af7e 100644
--- a/src/openvpn/socket.h
+++ b/src/openvpn/soc= ket.h
@@ -638,6 +638,11 @@
= struct link_socket_actual *to);


+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsi= gn-conversion"
+= #endif
+
static inline ssize_t

link_socket_write_udp_posix(str= uct link_socket *sock, struct buffer *buf,
= struct link_socket_actual *to)
@@ -660,6 +665,= 10 @@
return send(sock->sd, BPTR(buf), BLEN(buf), M= SG_NOSIGNAL);
}

+#if defined(__GNUC__) || defined(__clang__)<= /span>
+#pragma GCC diagnost= ic pop
+#endif=
+
#endif /= * ifdef _WIN32 */

static inline ssize_t<= /span>
diff --git a/src/openvpn/ssl_util.c b/src/openvpn/ssl_util.= c
index 50e8c03..10970e8 100644
--- a/src/o= penvpn/ssl_util.c
+++ b/src/openvpn/ssl_util.c
@@ -56,6 +56,12 @@

return var_value;
}


+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-W= conversion"
+#pr= agma GCC diagnostic ignored "-Wsign-conversion"
+#endif
+
unsigned int
ex= tract_iv_proto(const char *peer_info)
{
@@= -290,11 +296,6 @@
return NULL;
}

-#if def= ined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"= ;
-#endif
-

int
get_num_elements(const char *string, char delimiter)

{=
diff --git a/src/openvpn/status.c b/src/openvpn/status.c
index a9f9498..d3f30b39 100644
--- a/src/ope= nvpn/status.c
+++ b/src/openvpn/status.c
@@= -210,6 +210,7 @@
#if defined(__GNUC__) || defined(__clang= __)
#pragma GCC diagnostic push
#pragma G= CC diagnostic ignored "-Wconversion"
+#pragma GCC diagnostic ignored "-Wsign-conv= ersion"
#endif

#de= fine STATUS_PRINTF_MAXLEN 512
diff --git a/src/openvpn/wfp_= block.c b/src/openvpn/wfp_block.c
index 506d41b..669031a 10= 0644
--- a/src/openvpn/wfp_block.c
+++ b/sr= c/openvpn/wfp_block.c
@@ -131,6 +131,11 @@
= return err;
}

+#if defined(__GNUC__) || defined(__clang_= _)
+#pragma GCC diagn= ostic push
+#pragma G= CC diagnostic ignored "-Wsign-conversion"
+#endif
+
/*
* Block outgoin= g local traffic, possibly DNS only, except for
* (i) adap= ter with the specified index (and loopback, if all is blocked)
@@ -340,6 +345,10 @@

return err;
= }

+= #if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
DWORD
delete_wfp_block= _filters(HANDLE engine_handle)
{
diff --gi= t a/src/openvpn/xkey_provider.c b/src/openvpn/xkey_provider.c
index 1819ab0..8dfbc1a 100644

--- a/src/openvpn/xkey_pro= vider.c
+++ b/src/openvpn/xkey_provider.c
@= @ -940,6 +940,11 @@
return ret;
}

+#if d= efined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conv= ersion"
+#endif<= /span>
+
st= atic int
signature_sign(void *ctx, unsigned char *sig, siz= e_t *siglen, size_t sigsize,
const unsigned= char *tbs, size_t tbslen)
@@ -1074,6 +1079,10 @@ return signature_sign(ctx, sig, siglen, sigsize, buf, sz);
}

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
<= span style=3D"color: hsl(120, 100%, 40%);">+#endif

+
/* Sign digest using nativ= e sign function -- will only work for native keys
*/
int
diff --git a/src/openvpnmsica/dllmain.c b/= src/openvpnmsica/dllmain.c
index e7d4a4b..e57285d 100644
--- a/src/openvpnmsica/dllmain.c
+++ b/src/op= envpnmsica/dllmain.c
@@ -98,6 +98,10 @@
= return true;
}

+#if defined(__GNUC__) || defined(__clang_= _)
+#pragma GCC diagn= ostic push
+#pragma G= CC diagnostic ignored "-Wsign-conversion"
+#endif

= void
x_msg_va(const unsigned int flags, const char *forma= t, va_list arglist)
diff --git a/src/openvpnserv/common.c b= /src/openvpnserv/common.c
index a42c65d..38b6de6 100644
--- a/src/openvpnserv/common.c
+++ b/src/openv= pnserv/common.c
@@ -26,6 +26,11 @@
LPCWSTR= service_instance =3D L"";
static wchar_t win_sy= s_path[MAX_PATH];

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
<= br>+#pragma GCC diagnostic igno= red "-Wsign-conversion"
+#endif
= +
static DWORD
GetRegString(HKEY key, LPC= WSTR value, LPWSTR data, DWORD size, LPCWSTR default_value)
{

@@ -52,7 +57,6 @@
return ERROR_SUC= CESS;
}

-
DWORD
GetOpenvpnSet= tings(settings_t *s)
{
@@ -274,6 +278,10 @= @
return utf16;
}

+#if defined(__GNUC__)= || defined(__clang__)
+#endif
+
const wchar_t *
get_win_sys_path(void)
{
diff --git a/src/openvpnserv/interactive.c b= /src/openvpnserv/interactive.c
index ce0d4dd..1bddd24 10064= 4
--- a/src/openvpnserv/interactive.c
+++ b= /src/openvpnserv/interactive.c
@@ -512,6 +512,11 @@<= br> free(sud->directory);
}
=
+#if defined(__GNUC_= _) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"=
+#pragma GCC diagnostic ign= ored "-Wsign-conversion"
+#endif

static SOCKADDR_IN= ET
sockaddr_inet(short family, inet_address_t *addr)
@@ -1383,11 +1388,6 @@
return TRUE;<= br> }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "= -Wconversion"

-#en= dif
-
= /**
* Prepare DNS domain "SearchList" registry = value, so additional
* VPN domains can be added and its o= riginal state can be restored
@@ -2619,10 +2619,6 @@=
return err;
}

<= span style=3D"color: hsl(0, 100%, 40%);">-#if defined(__GNUC__) || defined(= __clang__)

-#pragma GCC= diagnostic pop
-#endif=
-
/**=
* Return the registry key where NRPT rules are stored
*
@@ -3561,6 +3557,9 @@
= return 0;
}

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic= pop
+#endif
static DWORD WINAPI
ServiceCtrl= Interactive(DWORD ctrl_code, DWORD event, LPVOID data, LPVOID ctx)diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c
in= dex b633e77..fb19118 100644
--- a/src/tapctl/tap.c+++ b/src/tapctl/tap.c
@@ -100,6 +100,11 @@<= br> return fptr;
}

<= span style=3D"color: hsl(120, 100%, 40%);">+#if defined(__GNUC__) || define= d(__clang__)

+#pragma= GCC diagnostic push
= +#pragma GCC diagnostic ignored "-Wsign-conversion"
+#endif

+
/**
* Retu= rns length of string of strings
*
diff --= git a/tests/unit_tests/openvpn/mock_get_random.c b/tests/unit_tests/openvpn= /mock_get_random.c
index 77db18e..58ca5f0 100644
= --- a/tests/unit_tests/openvpn/mock_get_random.c
+++ = b/tests/unit_tests/openvpn/mock_get_random.c
@@ -28,6 +28,1= 1 @@
#include <stdint.h>
#include &= lt;cmocka.h>

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push+#pragma GCC diagnostic ignore= d "-Wsign-conversion"
+#endif
+<= /span>
unsigned long
get_random(void)
= {
@@ -35,6 +40,10 @@
return ran= d();
}

+#if defined(__GNUC__) || defined(__clang__)+#pragma GCC diagnostic pop
+#endif
+

void
prng_bytes(uint8_t *output, int len)

{
diff --git a/tests/unit_tests/openvpn/mock_msg.c b/tests/unit_tests/openv= pn/mock_msg.c

index 603520b..38e036e 100644
--- a/tests/unit_tests/openvpn/mock_msg.c

+++ b/tests/unit= _tests/openvpn/mock_msg.c
@@ -45,6 +45,10 @@

char mock_msg_buf[MOCK_MSG_BUF];

+#if defined(__GNUC__) |= | defined(__clang__)
= +#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#endif
<= /span>
void
mock_set_debug_level(int level)
@@ -70,6 +74,10 @@
return x_debug_level;
}

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
void
x= _msg_va(const unsigned int flags, const char *format, va_list arglist)
{
diff --git a/tests/unit_tests/openvpn/test_n= etworking.c b/tests/unit_tests/openvpn/test_networking.c
in= dex f2da83e..4bda473 100644
--- a/tests/unit_tests/openvpn/= test_networking.c
+++ b/tests/unit_tests/openvpn/test_netwo= rking.c
@@ -39,6 +39,11 @@
return net_= iface_del(NULL, name);
}

+#if defined(__GNUC__) || defined(__= clang__)

+#pragma GCC= diagnostic push
+#pr= agma GCC diagnostic ignored "-Wsign-conversion"
+#endif
+
static int
net_= _iface_mtu_set(int mtu)
{
@@ -47,6 +52,10 = @@
return net_iface_mtu_set(NULL, iface, mtu);<= br> }

+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif

+
static int
n= et__addr_v4_add(const char *addr_str, int prefixlen)
{

To view, visit change 1186. To unsubscribe, or= for help writing mail filters, visit settings.

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iecf502ec811e99c56647b2d4529= 8fa0fb66960fb
Gerrit-Change-Number: 1186
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
--l2eTwLZuXto=--