Browse code

Enable -Wconversion -Wno-sign-conversion by default

Grand-father all known locations of existing errors,
so that -Werror builds still pass and we do not spam
build logs.

Still, this should give us a much better roadmap to
work on these issues one by one while still enabling
the warnings for a lot of code-paths.

In general I did go for least amount of pragmas, so
usually there is only one override per file, covering
ALL of the failures in that file. While this protects
a lot of code that doesn't need it, it also cut down
the amount of pragmas by a lot.

This does cover gcc builds including mingw and clang
builds. Does not cover MSVC.

Once the amount of issues has been suitable reduced
more warnings could be enabled.

Change-Id: Iad5b00c35a1f1993b1fa99e8b945ab17b230ef59
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1168
Message-Id: <20250924122755.14391-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33181.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Frank Lichtenheld authored on 2025/09/24 21:27:47
Showing 69 changed files
... ...
@@ -113,8 +113,7 @@ else ()
113 113
     check_and_add_compiler_flag(-Wno-stringop-truncation NoStringOpTruncation)
114 114
     check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes)
115 115
     check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition)
116
-    # We are not ready for this
117
-    #add_compile_options(-Wconversion -Wno-sign-conversion)
116
+    add_compile_options(-Wconversion -Wno-sign-conversion)
118 117
     add_compile_options(-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter)
119 118
     # clang doesn't have the different levels but also doesn't include it in -Wextra
120 119
     check_and_add_compiler_flag(-Wimplicit-fallthrough=2 GCCImplicitFallthrough)
... ...
@@ -1397,6 +1397,7 @@ AC_DEFUN([ACL_CHECK_ADD_COMPILE_FLAGS], [
1397 1397
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation])
1398 1398
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wstrict-prototypes])
1399 1399
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wold-style-definition])
1400
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wconversion -Wno-sign-conversion])
1400 1401
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
1401 1402
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter])
1402 1403
 # clang doesn't have the different levels but also doesn't include it in -Wextra
... ...
@@ -88,6 +88,11 @@ lz4v2_compress(struct buffer *buf, struct buffer work, struct compress_context *
88 88
     compv2_escape_data_ifneeded(buf);
89 89
 }
90 90
 
91
+#if defined(__GNUC__) || defined(__clang__)
92
+#pragma GCC diagnostic push
93
+#pragma GCC diagnostic ignored "-Wconversion"
94
+#endif
95
+
91 96
 static void
92 97
 do_lz4_decompress(size_t zlen_max, struct buffer *work, struct buffer *buf,
93 98
                   struct compress_context *compctx)
... ...
@@ -113,6 +118,10 @@ do_lz4_decompress(size_t zlen_max, struct buffer *work, struct buffer *buf,
113 113
     *buf = *work;
114 114
 }
115 115
 
116
+#if defined(__GNUC__) || defined(__clang__)
117
+#pragma GCC diagnostic pop
118
+#endif
119
+
116 120
 static void
117 121
 lz4_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
118 122
                const struct frame *frame)
... ...
@@ -45,6 +45,11 @@
45 45
 
46 46
 #include "win32.h"
47 47
 
48
+#if defined(__GNUC__) || defined(__clang__)
49
+#pragma GCC diagnostic push
50
+#pragma GCC diagnostic ignored "-Wconversion"
51
+#endif
52
+
48 53
 /**
49 54
  * Get input from a Windows console.
50 55
  *
... ...
@@ -134,6 +139,10 @@ get_console_input_win32(const char *prompt, const bool echo, char *input, const
134 134
     return false;
135 135
 }
136 136
 
137
+#if defined(__GNUC__) || defined(__clang__)
138
+#pragma GCC diagnostic pop
139
+#endif
140
+
137 141
 #endif /* _WIN32 */
138 142
 
139 143
 
... ...
@@ -264,6 +273,10 @@ get_console_input(const char *prompt, const bool echo, char *input, const int ca
264 264
     return ret;
265 265
 }
266 266
 
267
+#if defined(__GNUC__) || defined(__clang__)
268
+#pragma GCC diagnostic push
269
+#pragma GCC diagnostic ignored "-Wconversion"
270
+#endif
267 271
 
268 272
 /**
269 273
  * @copydoc query_user_exec()
... ...
@@ -296,3 +309,7 @@ query_user_exec_builtin(void)
296 296
 
297 297
     return ret;
298 298
 }
299
+
300
+#if defined(__GNUC__) || defined(__clang__)
301
+#pragma GCC diagnostic pop
302
+#endif
... ...
@@ -186,6 +186,11 @@ err:
186 186
     return;
187 187
 }
188 188
 
189
+#if defined(__GNUC__) || defined(__clang__)
190
+#pragma GCC diagnostic push
191
+#pragma GCC diagnostic ignored "-Wconversion"
192
+#endif
193
+
189 194
 static void
190 195
 openvpn_encrypt_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt)
191 196
 {
... ...
@@ -1532,6 +1537,10 @@ read_key_file(struct key2 *key2, const char *file, const unsigned int flags)
1532 1532
     gc_free(&gc);
1533 1533
 }
1534 1534
 
1535
+#if defined(__GNUC__) || defined(__clang__)
1536
+#pragma GCC diagnostic pop
1537
+#endif
1538
+
1535 1539
 int
1536 1540
 write_key_file(const int nkeys, const char *filename)
1537 1541
 {
... ...
@@ -72,6 +72,11 @@ ovpn_hkdf_expand(const uint8_t *secret, const uint8_t *info, int info_len, uint8
72 72
     hmac_ctx_free(hmac_ctx);
73 73
 }
74 74
 
75
+#if defined(__GNUC__) || defined(__clang__)
76
+#pragma GCC diagnostic push
77
+#pragma GCC diagnostic ignored "-Wconversion"
78
+#endif
79
+
75 80
 bool
76 81
 ovpn_expand_label(const uint8_t *secret, size_t secret_len, const uint8_t *label, size_t label_len,
77 82
                   const uint8_t *context, size_t context_len, uint8_t *out, uint16_t out_len)
... ...
@@ -163,6 +168,10 @@ epoch_data_key_derive(struct key_parameters *key, const struct epoch_key *epoch_
163 163
     key->epoch = epoch_key->epoch;
164 164
 }
165 165
 
166
+#if defined(__GNUC__) || defined(__clang__)
167
+#pragma GCC diagnostic pop
168
+#endif
169
+
166 170
 static void
167 171
 epoch_init_send_key_ctx(struct crypto_options *co)
168 172
 {
... ...
@@ -230,6 +230,11 @@ show_available_engines(void)
230 230
            "available\n");
231 231
 }
232 232
 
233
+#if defined(__GNUC__) || defined(__clang__)
234
+#pragma GCC diagnostic push
235
+#pragma GCC diagnostic ignored "-Wconversion"
236
+#endif
237
+
233 238
 bool
234 239
 crypto_pem_encode(const char *name, struct buffer *dst, const struct buffer *src,
235 240
                   struct gc_arena *gc)
... ...
@@ -760,7 +765,6 @@ cipher_ctx_final_check_tag(mbedtls_cipher_context_t *ctx, uint8_t *dst, int *dst
760 760
     return 1;
761 761
 }
762 762
 
763
-
764 763
 /*
765 764
  *
766 765
  * Generic message digest information functions
... ...
@@ -1119,4 +1123,9 @@ ssl_tls1_PRF(const uint8_t *label, size_t label_len, const uint8_t *sec, size_t
1119 1119
     return true;
1120 1120
 }
1121 1121
 #endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */
1122
+
1123
+#if defined(__GNUC__) || defined(__clang__)
1124
+#pragma GCC diagnostic pop
1125
+#endif
1126
+
1122 1127
 #endif /* ENABLE_CRYPTO_MBEDTLS */
... ...
@@ -895,6 +895,10 @@ cipher_ctx_mode(const EVP_CIPHER_CTX *ctx)
895 895
     return EVP_CIPHER_CTX_mode(ctx);
896 896
 }
897 897
 
898
+#if defined(__GNUC__) || defined(__clang__)
899
+#pragma GCC diagnostic push
900
+#pragma GCC diagnostic ignored "-Wconversion"
901
+#endif
898 902
 
899 903
 bool
900 904
 cipher_ctx_mode_cbc(const cipher_ctx_t *ctx)
... ...
@@ -999,6 +1003,9 @@ cipher_ctx_final_check_tag(EVP_CIPHER_CTX *ctx, uint8_t *dst, int *dst_len, uint
999 999
     return cipher_ctx_final(ctx, dst, dst_len);
1000 1000
 }
1001 1001
 
1002
+#if defined(__GNUC__) || defined(__clang__)
1003
+#pragma GCC diagnostic pop
1004
+#endif
1002 1005
 
1003 1006
 /*
1004 1007
  *
... ...
@@ -1214,12 +1221,21 @@ hmac_ctx_cleanup(HMAC_CTX *ctx)
1214 1214
     HMAC_CTX_reset(ctx);
1215 1215
 }
1216 1216
 
1217
+#if defined(__GNUC__) || defined(__clang__)
1218
+#pragma GCC diagnostic push
1219
+#pragma GCC diagnostic ignored "-Wconversion"
1220
+#endif
1221
+
1217 1222
 int
1218 1223
 hmac_ctx_size(HMAC_CTX *ctx)
1219 1224
 {
1220 1225
     return HMAC_size(ctx);
1221 1226
 }
1222 1227
 
1228
+#if defined(__GNUC__) || defined(__clang__)
1229
+#pragma GCC diagnostic pop
1230
+#endif
1231
+
1223 1232
 void
1224 1233
 hmac_ctx_reset(HMAC_CTX *ctx)
1225 1234
 {
... ...
@@ -1398,6 +1414,11 @@ ssl_tls1_PRF(const uint8_t *label, size_t label_len, const uint8_t *sec, size_t
1398 1398
     CRYPTO_tls1_prf(EVP_md5_sha1(), out1, olen, sec, slen, label, label_len, NULL, 0, NULL, 0);
1399 1399
 }
1400 1400
 #elif !defined(LIBRESSL_VERSION_NUMBER) && !defined(ENABLE_CRYPTO_WOLFSSL)
1401
+#if defined(__GNUC__) || defined(__clang__)
1402
+#pragma GCC diagnostic push
1403
+#pragma GCC diagnostic ignored "-Wconversion"
1404
+#endif
1405
+
1401 1406
 bool
1402 1407
 ssl_tls1_PRF(const uint8_t *seed, size_t seed_len, const uint8_t *secret, size_t secret_len,
1403 1408
              uint8_t *output, size_t output_len)
... ...
@@ -1443,6 +1464,11 @@ out:
1443 1443
     EVP_PKEY_CTX_free(pctx);
1444 1444
     return ret;
1445 1445
 }
1446
+
1447
+#if defined(__GNUC__) || defined(__clang__)
1448
+#pragma GCC diagnostic pop
1449
+#endif
1450
+
1446 1451
 #else  /* if defined(LIBRESSL_VERSION_NUMBER) */
1447 1452
 /* LibreSSL and wolfSSL do not expose a TLS 1.0/1.1 PRF via the same APIs as
1448 1453
  * OpenSSL does. As result they will only be able to support
... ...
@@ -62,7 +62,7 @@ SSL_CTX_use_CryptoAPI_certificate(SSL_CTX *ssl_ctx, const char *cert_prop)
62 62
     return 0;
63 63
 }
64 64
 
65
-#else  /* HAVE_XKEY_PROVIDER */
65
+#else /* HAVE_XKEY_PROVIDER */
66 66
 
67 67
 static XKEY_EXTERNAL_SIGN_fn xkey_cng_sign;
68 68
 
... ...
@@ -342,6 +342,11 @@ out:
342 342
     return rv;
343 343
 }
344 344
 
345
+#if defined(__GNUC__) || defined(__clang__)
346
+#pragma GCC diagnostic push
347
+#pragma GCC diagnostic ignored "-Wconversion"
348
+#endif
349
+
345 350
 /** Sign hash in tbs using EC key in cd and NCryptSignHash */
346 351
 static int
347 352
 xkey_cng_ec_sign(CAPI_DATA *cd, unsigned char *sig, size_t *siglen, const unsigned char *tbs,
... ...
@@ -438,6 +443,10 @@ xkey_cng_rsa_sign(CAPI_DATA *cd, unsigned char *sig, size_t *siglen, const unsig
438 438
     return (*siglen > 0);
439 439
 }
440 440
 
441
+#if defined(__GNUC__) || defined(__clang__)
442
+#pragma GCC diagnostic pop
443
+#endif
444
+
441 445
 /** Dispatch sign op to xkey_cng_<rsa/ec>_sign */
442 446
 static int
443 447
 xkey_cng_sign(void *handle, unsigned char *sig, size_t *siglen, const unsigned char *tbs,
... ...
@@ -491,6 +491,11 @@ dco_check_pull_options(msglvl_t msglevel, const struct options *o)
491 491
     return true;
492 492
 }
493 493
 
494
+#if defined(__GNUC__) || defined(__clang__)
495
+#pragma GCC diagnostic push
496
+#pragma GCC diagnostic ignored "-Wconversion"
497
+#endif
498
+
494 499
 int
495 500
 dco_p2p_add_new_peer(struct context *c)
496 501
 {
... ...
@@ -645,6 +650,10 @@ dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
645 645
     return 0;
646 646
 }
647 647
 
648
+#if defined(__GNUC__) || defined(__clang__)
649
+#pragma GCC diagnostic pop
650
+#endif
651
+
648 652
 void
649 653
 dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
650 654
 {
... ...
@@ -72,6 +72,11 @@ sockaddr_to_nvlist(const struct sockaddr *sa)
72 72
     return (nvl);
73 73
 }
74 74
 
75
+#if defined(__GNUC__) || defined(__clang__)
76
+#pragma GCC diagnostic push
77
+#pragma GCC diagnostic ignored "-Wconversion"
78
+#endif
79
+
75 80
 static bool
76 81
 nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss)
77 82
 {
... ...
@@ -854,6 +859,10 @@ retry:
854 854
     return 0;
855 855
 }
856 856
 
857
+#if defined(__GNUC__) || defined(__clang__)
858
+#pragma GCC diagnostic pop
859
+#endif
860
+
857 861
 int
858 862
 dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
859 863
 {
... ...
@@ -62,6 +62,11 @@ void dco_check_key_ctx(const struct key_ctx_bi *key);
62 62
 
63 63
 typedef int (*ovpn_nl_cb)(struct nl_msg *msg, void *arg);
64 64
 
65
+#if defined(__GNUC__) || defined(__clang__)
66
+#pragma GCC diagnostic push
67
+#pragma GCC diagnostic ignored "-Wconversion"
68
+#endif
69
+
65 70
 /**
66 71
  * @brief resolves the netlink ID for ovpn-dco
67 72
  *
... ...
@@ -1298,4 +1303,8 @@ dco_get_supported_ciphers(void)
1298 1298
     return "AES-128-GCM:AES-256-GCM:AES-192-GCM:CHACHA20-POLY1305";
1299 1299
 }
1300 1300
 
1301
+#if defined(__GNUC__) || defined(__clang__)
1302
+#pragma GCC diagnostic pop
1303
+#endif
1304
+
1301 1305
 #endif /* defined(ENABLE_DCO) && defined(TARGET_LINUX) */
... ...
@@ -525,6 +525,11 @@ dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, in
525 525
     return 0;
526 526
 }
527 527
 
528
+#if defined(__GNUC__) || defined(__clang__)
529
+#pragma GCC diagnostic push
530
+#pragma GCC diagnostic ignored "-Wconversion"
531
+#endif
532
+
528 533
 int
529 534
 dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t slot,
530 535
             const uint8_t *encrypt_key, const uint8_t *encrypt_iv, const uint8_t *decrypt_key,
... ...
@@ -564,6 +569,11 @@ dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t s
564 564
     }
565 565
     return 0;
566 566
 }
567
+
568
+#if defined(__GNUC__) || defined(__clang__)
569
+#pragma GCC diagnostic pop
570
+#endif
571
+
567 572
 int
568 573
 dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot)
569 574
 {
... ...
@@ -72,6 +72,11 @@ get_dhcp_message_type(const struct dhcp *dhcp, const int optlen)
72 72
     return -1;
73 73
 }
74 74
 
75
+#if defined(__GNUC__) || defined(__clang__)
76
+#pragma GCC diagnostic push
77
+#pragma GCC diagnostic ignored "-Wconversion"
78
+#endif
79
+
75 80
 static in_addr_t
76 81
 do_extract(struct dhcp *dhcp, int optlen)
77 82
 {
... ...
@@ -185,3 +190,7 @@ dhcp_extract_router_msg(struct buffer *ipbuf)
185 185
     }
186 186
     return 0;
187 187
 }
188
+
189
+#if defined(__GNUC__) || defined(__clang__)
190
+#pragma GCC diagnostic pop
191
+#endif
... ...
@@ -65,6 +65,11 @@
65 65
 #define SELECT_MAX_FDS 256
66 66
 #endif
67 67
 
68
+#if defined(__GNUC__) || defined(__clang__)
69
+#pragma GCC diagnostic push
70
+#pragma GCC diagnostic ignored "-Wconversion"
71
+#endif
72
+
68 73
 static inline int
69 74
 tv_to_ms_timeout(const struct timeval *tv)
70 75
 {
... ...
@@ -78,6 +83,10 @@ tv_to_ms_timeout(const struct timeval *tv)
78 78
     }
79 79
 }
80 80
 
81
+#if defined(__GNUC__) || defined(__clang__)
82
+#pragma GCC diagnostic pop
83
+#endif
84
+
81 85
 #ifdef _WIN32
82 86
 
83 87
 struct we_set
... ...
@@ -367,6 +367,11 @@ check_connection_established(struct context *c)
367 367
     }
368 368
 }
369 369
 
370
+#if defined(__GNUC__) || defined(__clang__)
371
+#pragma GCC diagnostic push
372
+#pragma GCC diagnostic ignored "-Wconversion"
373
+#endif
374
+
370 375
 bool
371 376
 send_control_channel_string_dowork(struct tls_session *session, const char *str,
372 377
                                    msglvl_t msglevel)
... ...
@@ -1966,6 +1971,10 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
1966 1966
     perf_pop();
1967 1967
 }
1968 1968
 
1969
+#if defined(__GNUC__) || defined(__clang__)
1970
+#pragma GCC diagnostic pop
1971
+#endif
1972
+
1969 1973
 void
1970 1974
 pre_select(struct context *c)
1971 1975
 {
... ...
@@ -98,6 +98,11 @@ flip(int n)
98 98
     return (get_random() % n) == 0;
99 99
 }
100 100
 
101
+#if defined(__GNUC__) || defined(__clang__)
102
+#pragma GCC diagnostic push
103
+#pragma GCC diagnostic ignored "-Wconversion"
104
+#endif
105
+
101 106
 /*
102 107
  * Return uniformly distributed random number between
103 108
  * low and high.
... ...
@@ -229,4 +234,9 @@ corrupt_gremlin(struct buffer *buf, int flags)
229 229
         }
230 230
     }
231 231
 }
232
+
233
+#if defined(__GNUC__) || defined(__clang__)
234
+#pragma GCC diagnostic pop
235
+#endif
236
+
232 237
 #endif /* ifdef ENABLE_DEBUG */
... ...
@@ -61,6 +61,11 @@ CvtHex(IN HASH Bin, OUT HASHHEX Hex)
61 61
     Hex[HASHHEXLEN] = '\0';
62 62
 }
63 63
 
64
+#if defined(__GNUC__) || defined(__clang__)
65
+#pragma GCC diagnostic push
66
+#pragma GCC diagnostic ignored "-Wconversion"
67
+#endif
68
+
64 69
 /* calculate H(A1) as per spec */
65 70
 void
66 71
 DigestCalcHA1(IN char *pszAlg, IN char *pszUserName, IN char *pszRealm, IN char *pszPassword,
... ...
@@ -145,4 +150,8 @@ DigestCalcResponse(IN HASHHEX HA1,         /* H(A1) */
145 145
     CvtHex(RespHash, Response);
146 146
 }
147 147
 
148
+#if defined(__GNUC__) || defined(__clang__)
149
+#pragma GCC diagnostic pop
150
+#endif
151
+
148 152
 #endif /* if PROXY_DIGEST_AUTH */
... ...
@@ -455,6 +455,11 @@ ce_management_query_remote(struct context *c)
455 455
 }
456 456
 #endif /* ENABLE_MANAGEMENT */
457 457
 
458
+#if defined(__GNUC__) || defined(__clang__)
459
+#pragma GCC diagnostic push
460
+#pragma GCC diagnostic ignored "-Wconversion"
461
+#endif
462
+
458 463
 /*
459 464
  * Initialize and possibly randomize the connection list.
460 465
  *
... ...
@@ -3490,6 +3495,10 @@ do_init_frame_tls(struct context *c)
3490 3490
     }
3491 3491
 }
3492 3492
 
3493
+#if defined(__GNUC__) || defined(__clang__)
3494
+#pragma GCC diagnostic pop
3495
+#endif
3496
+
3493 3497
 /*
3494 3498
  * No encryption or authentication.
3495 3499
  */
... ...
@@ -38,6 +38,11 @@ interval_init(struct interval *top, int horizon, int refresh)
38 38
     top->horizon = horizon;
39 39
 }
40 40
 
41
+#if defined(__GNUC__) || defined(__clang__)
42
+#pragma GCC diagnostic push
43
+#pragma GCC diagnostic ignored "-Wconversion"
44
+#endif
45
+
41 46
 bool
42 47
 event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et_const_retry)
43 48
 {
... ...
@@ -77,3 +82,7 @@ event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et
77 77
     }
78 78
     return ret;
79 79
 }
80
+
81
+#if defined(__GNUC__) || defined(__clang__)
82
+#pragma GCC diagnostic pop
83
+#endif
... ...
@@ -72,6 +72,11 @@ lzo_compress(struct buffer *buf, struct buffer work, struct compress_context *co
72 72
     *header = NO_COMPRESS_BYTE;
73 73
 }
74 74
 
75
+#if defined(__GNUC__) || defined(__clang__)
76
+#pragma GCC diagnostic push
77
+#pragma GCC diagnostic ignored "-Wconversion"
78
+#endif
79
+
75 80
 static void
76 81
 lzo_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
77 82
                const struct frame *frame)
... ...
@@ -121,6 +126,10 @@ lzo_decompress(struct buffer *buf, struct buffer work, struct compress_context *
121 121
     }
122 122
 }
123 123
 
124
+#if defined(__GNUC__) || defined(__clang__)
125
+#pragma GCC diagnostic pop
126
+#endif
127
+
124 128
 const struct compress_alg lzo_alg = { "lzo", lzo_compress_init, lzo_compress_uninit, lzo_compress,
125 129
                                       lzo_decompress };
126 130
 #endif /* ENABLE_LZO */
... ...
@@ -206,6 +206,11 @@ man_password_needed(struct management *man)
206 206
     return man->settings.up.defined && !man->connection.password_verified;
207 207
 }
208 208
 
209
+#if defined(__GNUC__) || defined(__clang__)
210
+#pragma GCC diagnostic push
211
+#pragma GCC diagnostic ignored "-Wconversion"
212
+#endif
213
+
209 214
 static void
210 215
 man_check_password(struct management *man, const char *line)
211 216
 {
... ...
@@ -236,6 +241,10 @@ man_check_password(struct management *man, const char *line)
236 236
     }
237 237
 }
238 238
 
239
+#if defined(__GNUC__) || defined(__clang__)
240
+#pragma GCC diagnostic pop
241
+#endif
242
+
239 243
 static void
240 244
 man_update_io_state(struct management *man)
241 245
 {
... ...
@@ -2305,6 +2314,11 @@ managment_android_persisttun_action(struct management *man)
2305 2305
 
2306 2306
 #endif /* ifdef TARGET_ANDROID */
2307 2307
 
2308
+#if defined(__GNUC__) || defined(__clang__)
2309
+#pragma GCC diagnostic push
2310
+#pragma GCC diagnostic ignored "-Wconversion"
2311
+#endif
2312
+
2308 2313
 static int
2309 2314
 man_read(struct management *man)
2310 2315
 {
... ...
@@ -2442,6 +2456,10 @@ man_write(struct management *man)
2442 2442
     return sent;
2443 2443
 }
2444 2444
 
2445
+#if defined(__GNUC__) || defined(__clang__)
2446
+#pragma GCC diagnostic pop
2447
+#endif
2448
+
2445 2449
 static void
2446 2450
 man_connection_clear(struct man_connection *mc)
2447 2451
 {
... ...
@@ -34,6 +34,11 @@
34 34
 
35 35
 #include "memdbg.h"
36 36
 
37
+#if defined(__GNUC__) || defined(__clang__)
38
+#pragma GCC diagnostic push
39
+#pragma GCC diagnostic ignored "-Wconversion"
40
+#endif
41
+
37 42
 struct mbuf_set *
38 43
 mbuf_init(unsigned int size)
39 44
 {
... ...
@@ -44,6 +49,10 @@ mbuf_init(unsigned int size)
44 44
     return ret;
45 45
 }
46 46
 
47
+#if defined(__GNUC__) || defined(__clang__)
48
+#pragma GCC diagnostic pop
49
+#endif
50
+
47 51
 void
48 52
 mbuf_free(struct mbuf_set *ms)
49 53
 {
... ...
@@ -72,6 +72,11 @@ set_std_files_to_null(bool stdin_only)
72 72
 #endif
73 73
 }
74 74
 
75
+#if defined(__GNUC__) || defined(__clang__)
76
+#pragma GCC diagnostic push
77
+#pragma GCC diagnostic ignored "-Wconversion"
78
+#endif
79
+
75 80
 #ifdef ENABLE_MANAGEMENT
76 81
 /* Get username/password from the management interface */
77 82
 static bool
... ...
@@ -184,6 +189,10 @@ parse_auth_challenge(const char *auth_challenge, struct gc_arena *gc)
184 184
 
185 185
 #endif /* ifdef ENABLE_MANAGEMENT */
186 186
 
187
+#if defined(__GNUC__) || defined(__clang__)
188
+#pragma GCC diagnostic pop
189
+#endif
190
+
187 191
 /*
188 192
  * Get and store a username/password
189 193
  */
... ...
@@ -103,6 +103,11 @@ mroute_learnable_address(const struct mroute_addr *addr, struct gc_arena *gc)
103 103
     return true;
104 104
 }
105 105
 
106
+#if defined(__GNUC__) || defined(__clang__)
107
+#pragma GCC diagnostic push
108
+#pragma GCC diagnostic ignored "-Wconversion"
109
+#endif
110
+
106 111
 static inline void
107 112
 mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src, unsigned int mask)
108 113
 {
... ...
@@ -547,6 +552,10 @@ mroute_helper_del_iroute46(struct mroute_helper *mh, int netbits)
547 547
     }
548 548
 }
549 549
 
550
+#if defined(__GNUC__) || defined(__clang__)
551
+#pragma GCC diagnostic pop
552
+#endif
553
+
550 554
 void
551 555
 mroute_helper_free(struct mroute_helper *mh)
552 556
 {
... ...
@@ -130,6 +130,11 @@ mss_fixup_ipv6(struct buffer *buf, uint16_t maxmss)
130 130
     }
131 131
 }
132 132
 
133
+#if defined(__GNUC__) || defined(__clang__)
134
+#pragma GCC diagnostic push
135
+#pragma GCC diagnostic ignored "-Wconversion"
136
+#endif
137
+
133 138
 /*
134 139
  * change TCP MSS option in SYN/SYN-ACK packets, if present
135 140
  * this is generic for IPv4 and IPv6, as the TCP header is the same
... ...
@@ -199,6 +204,10 @@ mss_fixup_dowork(struct buffer *buf, uint16_t maxmss)
199 199
     }
200 200
 }
201 201
 
202
+#if defined(__GNUC__) || defined(__clang__)
203
+#pragma GCC diagnostic pop
204
+#endif
205
+
202 206
 static inline size_t
203 207
 adjust_payload_max_cbc(const struct key_type *kt, size_t target)
204 208
 {
... ...
@@ -45,6 +45,11 @@ struct ta_iow_flags
45 45
     unsigned int sock;
46 46
 };
47 47
 
48
+#if defined(__GNUC__) || defined(__clang__)
49
+#pragma GCC diagnostic push
50
+#pragma GCC diagnostic ignored "-Wconversion"
51
+#endif
52
+
48 53
 struct multi_instance *
49 54
 multi_create_instance_tcp(struct multi_context *m, struct link_socket *sock)
50 55
 {
... ...
@@ -120,6 +125,10 @@ multi_tcp_instance_specific_init(struct multi_context *m, struct multi_instance
120 120
     return true;
121 121
 }
122 122
 
123
+#if defined(__GNUC__) || defined(__clang__)
124
+#pragma GCC diagnostic pop
125
+#endif
126
+
123 127
 void
124 128
 multi_tcp_instance_specific_free(struct multi_instance *mi)
125 129
 {
... ...
@@ -280,6 +280,11 @@ struct probehdr
280 280
     struct timeval tv;
281 281
 };
282 282
 
283
+#if defined(__GNUC__) || defined(__clang__)
284
+#pragma GCC diagnostic push
285
+#pragma GCC diagnostic ignored "-Wconversion"
286
+#endif
287
+
283 288
 const char *
284 289
 format_extended_socket_error(int fd, int *mtu, struct gc_arena *gc)
285 290
 {
... ...
@@ -389,6 +394,10 @@ exit:
389 389
     return BSTR(&out);
390 390
 }
391 391
 
392
+#if defined(__GNUC__) || defined(__clang__)
393
+#pragma GCC diagnostic pop
394
+#endif
395
+
392 396
 void
393 397
 set_sock_extended_error_passing(int sd, sa_family_t proto_af)
394 398
 {
... ...
@@ -180,6 +180,11 @@ do_pre_decrypt_check(struct multi_context *m, struct tls_pre_decrypt_state *stat
180 180
     return false;
181 181
 }
182 182
 
183
+#if defined(__GNUC__) || defined(__clang__)
184
+#pragma GCC diagnostic push
185
+#pragma GCC diagnostic ignored "-Wconversion"
186
+#endif
187
+
183 188
 /*
184 189
  * Get a client instance based on real address.  If
185 190
  * the instance doesn't exist, create it while
... ...
@@ -310,6 +315,10 @@ multi_get_create_instance_udp(struct multi_context *m, bool *floated, struct lin
310 310
     return mi;
311 311
 }
312 312
 
313
+#if defined(__GNUC__) || defined(__clang__)
314
+#pragma GCC diagnostic pop
315
+#endif
316
+
313 317
 /*
314 318
  * Send a packet to UDP socket.
315 319
  */
... ...
@@ -256,6 +256,11 @@ cid_compare_function(const void *key1, const void *key2)
256 256
 
257 257
 #endif
258 258
 
259
+#if defined(__GNUC__) || defined(__clang__)
260
+#pragma GCC diagnostic push
261
+#pragma GCC diagnostic ignored "-Wconversion"
262
+#endif
263
+
259 264
 #ifdef ENABLE_ASYNC_PUSH
260 265
 static uint32_t
261 266
 /*
... ...
@@ -3982,6 +3987,10 @@ management_callback_kill_by_addr(void *arg, const in_addr_t addr, const int port
3982 3982
     return count;
3983 3983
 }
3984 3984
 
3985
+#if defined(__GNUC__) || defined(__clang__)
3986
+#pragma GCC diagnostic pop
3987
+#endif
3988
+
3985 3989
 static void
3986 3990
 management_delete_event(void *arg, event_t event)
3987 3991
 {
... ...
@@ -131,6 +131,11 @@ struct sitnl_route_data_cb
131 131
     inet_address_t gw;
132 132
 };
133 133
 
134
+#if defined(__GNUC__) || defined(__clang__)
135
+#pragma GCC diagnostic push
136
+#pragma GCC diagnostic ignored "-Wconversion"
137
+#endif
138
+
134 139
 /**
135 140
  * Helper function used to easily add attributes to a rtnl message
136 141
  */
... ...
@@ -1469,6 +1474,10 @@ net_iface_del(openvpn_net_ctx_t *ctx, const char *iface)
1469 1469
     return sitnl_send(&req.n, 0, 0, NULL, NULL);
1470 1470
 }
1471 1471
 
1472
+#if defined(__GNUC__) || defined(__clang__)
1473
+#pragma GCC diagnostic pop
1474
+#endif
1475
+
1472 1476
 #endif /* !ENABLE_SITNL */
1473 1477
 
1474 1478
 #endif /* TARGET_LINUX */
... ...
@@ -74,6 +74,11 @@ gen_hmac_md5(const uint8_t *data, int data_len, const uint8_t *key, uint8_t *res
74 74
     hmac_ctx_free(hmac_ctx);
75 75
 }
76 76
 
77
+#if defined(__GNUC__) || defined(__clang__)
78
+#pragma GCC diagnostic push
79
+#pragma GCC diagnostic ignored "-Wconversion"
80
+#endif
81
+
77 82
 static void
78 83
 gen_timestamp(uint8_t *timestamp)
79 84
 {
... ...
@@ -383,4 +388,8 @@ ntlm_phase_3(const struct http_proxy_info *p, const char *phase_2, struct gc_are
383 383
 
384 384
     return ((const char *)make_base64_string2((unsigned char *)phase3, phase3_bufpos, gc));
385 385
 }
386
+
387
+#if defined(__GNUC__) || defined(__clang__)
388
+#pragma GCC diagnostic pop
389
+#endif
386 390
 #endif /* if NTLM */
... ...
@@ -174,6 +174,11 @@ check_send_occ_req_dowork(struct context *c)
174 174
     }
175 175
 }
176 176
 
177
+#if defined(__GNUC__) || defined(__clang__)
178
+#pragma GCC diagnostic push
179
+#pragma GCC diagnostic ignored "-Wconversion"
180
+#endif
181
+
177 182
 void
178 183
 check_send_occ_load_test_dowork(struct context *c)
179 184
 {
... ...
@@ -347,6 +352,10 @@ check_send_occ_msg_dowork(struct context *c)
347 347
     c->c2.occ_op = -1;
348 348
 }
349 349
 
350
+#if defined(__GNUC__) || defined(__clang__)
351
+#pragma GCC diagnostic pop
352
+#endif
353
+
350 354
 void
351 355
 process_received_occ_msg(struct context *c)
352 356
 {
... ...
@@ -194,12 +194,21 @@ SSL_get0_peer_signature_name(const SSL *ssl, const char **sigalg)
194 194
           LIBRESSL_VERSION_NUMBER > 0x3050400fL) */
195 195
 
196 196
 #if OPENSSL_VERSION_NUMBER < 0x30200000L && OPENSSL_VERSION_NUMBER >= 0x30000000L
197
+#if defined(__GNUC__) || defined(__clang__)
198
+#pragma GCC diagnostic push
199
+#pragma GCC diagnostic ignored "-Wconversion"
200
+#endif
201
+
197 202
 static inline const char *
198 203
 SSL_get0_group_name(SSL *s)
199 204
 {
200 205
     int nid = SSL_get_negotiated_group(s);
201 206
     return SSL_group_to_name(s, nid);
202 207
 }
208
+
209
+#if defined(__GNUC__) || defined(__clang__)
210
+#pragma GCC diagnostic pop
211
+#endif
203 212
 #endif
204 213
 
205 214
 #endif /* OPENSSL_COMPAT_H_ */
... ...
@@ -1158,6 +1158,11 @@ ipv6_addr_safe_hexplusbits(const char *ipv6_prefix_spec)
1158 1158
     return get_ipv6_addr(ipv6_prefix_spec, &t_addr, &t_bits, M_WARN);
1159 1159
 }
1160 1160
 
1161
+#if defined(__GNUC__) || defined(__clang__)
1162
+#pragma GCC diagnostic push
1163
+#pragma GCC diagnostic ignored "-Wconversion"
1164
+#endif
1165
+
1161 1166
 static char *
1162 1167
 string_substitute(const char *src, int from, int to, struct gc_arena *gc)
1163 1168
 {
... ...
@@ -9900,6 +9905,10 @@ err:
9900 9900
     gc_free(&gc);
9901 9901
 }
9902 9902
 
9903
+#if defined(__GNUC__) || defined(__clang__)
9904
+#pragma GCC diagnostic pop
9905
+#endif
9906
+
9903 9907
 bool
9904 9908
 has_udp_in_local_list(const struct options *options)
9905 9909
 {
... ...
@@ -162,6 +162,11 @@ atoi_warn(const char *str, msglvl_t msglevel)
162 162
     return (int)i;
163 163
 }
164 164
 
165
+#if defined(__GNUC__) || defined(__clang__)
166
+#pragma GCC diagnostic push
167
+#pragma GCC diagnostic ignored "-Wconversion"
168
+#endif
169
+
165 170
 bool
166 171
 atoi_constrained(const char *str, int *value, const char *name, int min, int max, msglvl_t msglevel)
167 172
 {
... ...
@@ -193,6 +198,10 @@ atoi_constrained(const char *str, int *value, const char *name, int min, int max
193 193
     return true;
194 194
 }
195 195
 
196
+#if defined(__GNUC__) || defined(__clang__)
197
+#pragma GCC diagnostic pop
198
+#endif
199
+
196 200
 static const char *updatable_options[] = { "block-ipv6", "block-outside-dns",
197 201
                                            "dhcp-option", "dns",
198 202
                                            "ifconfig", "ifconfig-ipv6",
... ...
@@ -100,6 +100,11 @@ tv_string_abs(const struct timeval *tv, struct gc_arena *gc)
100 100
 
101 101
 /* format a time_t as ascii, or use current time if 0 */
102 102
 
103
+#if defined(__GNUC__) || defined(__clang__)
104
+#pragma GCC diagnostic push
105
+#pragma GCC diagnostic ignored "-Wconversion"
106
+#endif
107
+
103 108
 const char *
104 109
 time_string(time_t t, long usec, bool show_usec, struct gc_arena *gc)
105 110
 {
... ...
@@ -130,6 +135,10 @@ time_string(time_t t, long usec, bool show_usec, struct gc_arena *gc)
130 130
     return BSTR(&out);
131 131
 }
132 132
 
133
+#if defined(__GNUC__) || defined(__clang__)
134
+#pragma GCC diagnostic pop
135
+#endif
136
+
133 137
 /*
134 138
  * Limit the frequency of an event stream.
135 139
  *
... ...
@@ -59,6 +59,11 @@ void update_now(const time_t system_time);
59 59
 extern time_t now_usec;
60 60
 void update_now_usec(struct timeval *tv);
61 61
 
62
+#if defined(__GNUC__) || defined(__clang__)
63
+#pragma GCC diagnostic push
64
+#pragma GCC diagnostic ignored "-Wconversion"
65
+#endif
66
+
62 67
 static inline int
63 68
 openvpn_gettimeofday(struct timeval *tv, void *tz)
64 69
 {
... ...
@@ -236,6 +241,10 @@ tv_delta(struct timeval *dest, const struct timeval *t1, const struct timeval *t
236 236
     dest->tv_usec = usec;
237 237
 }
238 238
 
239
+#if defined(__GNUC__) || defined(__clang__)
240
+#pragma GCC diagnostic pop
241
+#endif
242
+
239 243
 #define TV_WITHIN_SIGMA_MAX_SEC  600
240 244
 #define TV_WITHIN_SIGMA_MAX_USEC (TV_WITHIN_SIGMA_MAX_SEC * 1000000)
241 245
 
... ...
@@ -71,6 +71,11 @@ packet_id_debug(msglvl_t msglevel, const struct packet_id_rec *p,
71 71
 #endif
72 72
 }
73 73
 
74
+#if defined(__GNUC__) || defined(__clang__)
75
+#pragma GCC diagnostic push
76
+#pragma GCC diagnostic ignored "-Wconversion"
77
+#endif
78
+
74 79
 static void
75 80
 packet_id_init_recv(struct packet_id_rec *rec, int seq_backtrack, int time_backtrack,
76 81
                     const char *name, int unit)
... ...
@@ -663,6 +668,10 @@ packet_id_read_epoch(struct packet_id_net *pin, struct buffer *buf)
663 663
     return epoch;
664 664
 }
665 665
 
666
+#if defined(__GNUC__) || defined(__clang__)
667
+#pragma GCC diagnostic pop
668
+#endif
669
+
666 670
 bool
667 671
 packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf)
668 672
 {
... ...
@@ -280,6 +280,11 @@ packet_id_persist_enabled(const struct packet_id_persist *p)
280 280
     return p->fd >= 0;
281 281
 }
282 282
 
283
+#if defined(__GNUC__) || defined(__clang__)
284
+#pragma GCC diagnostic push
285
+#pragma GCC diagnostic ignored "-Wconversion"
286
+#endif
287
+
283 288
 /* transfer packet_id -> packet_id_persist */
284 289
 static inline void
285 290
 packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *pid)
... ...
@@ -291,6 +296,10 @@ packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *
291 291
     }
292 292
 }
293 293
 
294
+#if defined(__GNUC__) || defined(__clang__)
295
+#pragma GCC diagnostic pop
296
+#endif
297
+
294 298
 /**
295 299
  * Reset the current send packet id to its initial state.
296 300
  * Use very carefully (e.g. in the standalone reset packet context) to
... ...
@@ -53,6 +53,11 @@ __mygettimeofday(struct timeval *tv)
53 53
 }
54 54
 #endif
55 55
 
56
+#if defined(__GNUC__) || defined(__clang__)
57
+#pragma GCC diagnostic push
58
+#pragma GCC diagnostic ignored "-Wconversion"
59
+#endif
60
+
56 61
 static void
57 62
 __mysleep(const unsigned long usec)
58 63
 {
... ...
@@ -558,6 +563,10 @@ cleanup:
558 558
     return success;
559 559
 }
560 560
 
561
+#if defined(__GNUC__) || defined(__clang__)
562
+#pragma GCC diagnostic pop
563
+#endif
564
+
561 565
 int
562 566
 tls_ctx_use_pkcs11(struct tls_root_ctx *const ssl_ctx, bool pkcs11_id_management,
563 567
                    const char *const pkcs11_id)
... ...
@@ -428,6 +428,11 @@ cleanup:
428 428
     return dn;
429 429
 }
430 430
 
431
+#if defined(__GNUC__) || defined(__clang__)
432
+#pragma GCC diagnostic push
433
+#pragma GCC diagnostic ignored "-Wconversion"
434
+#endif
435
+
431 436
 int
432 437
 pkcs11_certificate_serial(pkcs11h_certificate_t certificate, char *serial, size_t serial_len)
433 438
 {
... ...
@@ -468,4 +473,9 @@ cleanup:
468 468
 
469 469
     return ret;
470 470
 }
471
+
472
+#if defined(__GNUC__) || defined(__clang__)
473
+#pragma GCC diagnostic pop
474
+#endif
475
+
471 476
 #endif /* defined(ENABLE_PKCS11) && defined(ENABLE_OPENSSL) */
... ...
@@ -54,6 +54,11 @@ init_http_proxy_options_once(struct http_proxy_options **hpo, struct gc_arena *g
54 54
 }
55 55
 
56 56
 
57
+#if defined(__GNUC__) || defined(__clang__)
58
+#pragma GCC diagnostic push
59
+#pragma GCC diagnostic ignored "-Wconversion"
60
+#endif
61
+
57 62
 /* cached proxy username/password */
58 63
 static struct user_pass static_proxy_user_pass;
59 64
 
... ...
@@ -1063,3 +1068,7 @@ error:
1063 1063
     gc_free(&gc);
1064 1064
     return ret;
1065 1065
 }
1066
+
1067
+#if defined(__GNUC__) || defined(__clang__)
1068
+#pragma GCC diagnostic pop
1069
+#endif
... ...
@@ -475,6 +475,11 @@ proxy_entry_new(struct proxy_connection **list, struct event_set *es,
475 475
     return true;
476 476
 }
477 477
 
478
+#if defined(__GNUC__) || defined(__clang__)
479
+#pragma GCC diagnostic push
480
+#pragma GCC diagnostic ignored "-Wconversion"
481
+#endif
482
+
478 483
 /*
479 484
  * This function runs in the context of the background proxy process.
480 485
  * Receive a control message from the parent (sent by the port_share_sendmsg
... ...
@@ -792,6 +797,10 @@ done:
792 792
     msg(M_INFO, "PORT SHARE PROXY: proxy exiting");
793 793
 }
794 794
 
795
+#if defined(__GNUC__) || defined(__clang__)
796
+#pragma GCC diagnostic pop
797
+#endif
798
+
795 799
 /*
796 800
  * Called from the main OpenVPN process to enable the port
797 801
  * share proxy.
... ...
@@ -429,6 +429,10 @@ send_auth_failed(struct context *c, const char *client_reason)
429 429
     gc_free(&gc);
430 430
 }
431 431
 
432
+#if defined(__GNUC__) || defined(__clang__)
433
+#pragma GCC diagnostic push
434
+#pragma GCC diagnostic ignored "-Wconversion"
435
+#endif
432 436
 
433 437
 bool
434 438
 send_auth_pending_messages(struct tls_multi *tls_multi, struct tls_session *session,
... ...
@@ -1086,6 +1090,10 @@ process_incoming_push_reply(struct context *c, unsigned int permission_mask,
1086 1086
     return ret;
1087 1087
 }
1088 1088
 
1089
+#if defined(__GNUC__) || defined(__clang__)
1090
+#pragma GCC diagnostic pop
1091
+#endif
1092
+
1089 1093
 int
1090 1094
 process_incoming_push_msg(struct context *c, const struct buffer *buffer,
1091 1095
                           bool honor_received_options, unsigned int permission_mask,
... ...
@@ -9,6 +9,11 @@
9 9
 #include "multi.h"
10 10
 #endif
11 11
 
12
+#if defined(__GNUC__) || defined(__clang__)
13
+#pragma GCC diagnostic push
14
+#pragma GCC diagnostic ignored "-Wconversion"
15
+#endif
16
+
12 17
 int
13 18
 process_incoming_push_update(struct context *c, unsigned int permission_mask,
14 19
                              unsigned int *option_types_found, struct buffer *buf,
... ...
@@ -306,3 +311,7 @@ management_callback_send_push_update_by_cid(void *arg, unsigned long cid, const
306 306
     RETURN_UPDATE_STATUS(n_sent);
307 307
 }
308 308
 #endif /* ifdef ENABLE_MANAGEMENT */
309
+
310
+#if defined(__GNUC__) || defined(__clang__)
311
+#pragma GCC diagnostic pop
312
+#endif
... ...
@@ -687,6 +687,11 @@ reliable_schedule_now(struct reliable *rel)
687 687
     }
688 688
 }
689 689
 
690
+#if defined(__GNUC__) || defined(__clang__)
691
+#pragma GCC diagnostic push
692
+#pragma GCC diagnostic ignored "-Wconversion"
693
+#endif
694
+
690 695
 /* in how many seconds should we wake up to check for timeout */
691 696
 /* if we return BIG_TIMEOUT, nothing to wait for */
692 697
 interval_t
... ...
@@ -719,6 +724,10 @@ reliable_send_timeout(const struct reliable *rel)
719 719
     return ret;
720 720
 }
721 721
 
722
+#if defined(__GNUC__) || defined(__clang__)
723
+#pragma GCC diagnostic pop
724
+#endif
725
+
722 726
 /*
723 727
  * Enable an incoming buffer previously returned by a get function as active.
724 728
  */
... ...
@@ -1760,6 +1760,10 @@ done:
1760 1760
     return (status != RTA_ERROR);
1761 1761
 }
1762 1762
 
1763
+#if defined(__GNUC__) || defined(__clang__)
1764
+#pragma GCC diagnostic push
1765
+#pragma GCC diagnostic ignored "-Wconversion"
1766
+#endif
1763 1767
 
1764 1768
 void
1765 1769
 route_ipv6_clear_host_bits(struct route_ipv6 *r6)
... ...
@@ -2364,6 +2368,10 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, const st
2364 2364
     net_ctx_reset(ctx);
2365 2365
 }
2366 2366
 
2367
+#if defined(__GNUC__) || defined(__clang__)
2368
+#pragma GCC diagnostic pop
2369
+#endif
2370
+
2367 2371
 /*
2368 2372
  * The --redirect-gateway option requires OS-specific code below
2369 2373
  * to get the current default gateway.
... ...
@@ -3360,6 +3368,11 @@ struct rtmsg
3360 3360
 
3361 3361
 #define max(a, b) ((a) > (b) ? (a) : (b))
3362 3362
 
3363
+#if defined(__GNUC__) || defined(__clang__)
3364
+#pragma GCC diagnostic push
3365
+#pragma GCC diagnostic ignored "-Wconversion"
3366
+#endif
3367
+
3363 3368
 void
3364 3369
 get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
3365 3370
 {
... ...
@@ -3733,6 +3746,10 @@ done:
3733 3733
     }
3734 3734
 }
3735 3735
 
3736
+#if defined(__GNUC__) || defined(__clang__)
3737
+#pragma GCC diagnostic pop
3738
+#endif
3739
+
3736 3740
 #undef max
3737 3741
 
3738 3742
 #elif defined(TARGET_HAIKU)
... ...
@@ -65,6 +65,11 @@ schedule_entry_debug_info(const char *caller, const struct schedule_entry *e)
65 65
 }
66 66
 #endif
67 67
 
68
+#if defined(__GNUC__) || defined(__clang__)
69
+#pragma GCC diagnostic push
70
+#pragma GCC diagnostic ignored "-Wconversion"
71
+#endif
72
+
68 73
 static inline void
69 74
 schedule_set_pri(struct schedule_entry *e)
70 75
 {
... ...
@@ -75,6 +80,10 @@ schedule_set_pri(struct schedule_entry *e)
75 75
     }
76 76
 }
77 77
 
78
+#if defined(__GNUC__) || defined(__clang__)
79
+#pragma GCC diagnostic pop
80
+#endif
81
+
78 82
 /* This is the master key comparison routine.  A key is
79 83
  * simply a struct timeval containing the absolute time for
80 84
  * an event.  The unique treap priority (pri) is used to ensure
... ...
@@ -72,6 +72,11 @@ sf2gaf(const unsigned int getaddr_flags, const unsigned int sockflags)
72 72
     }
73 73
 }
74 74
 
75
+#if defined(__GNUC__) || defined(__clang__)
76
+#pragma GCC diagnostic push
77
+#pragma GCC diagnostic ignored "-Wconversion"
78
+#endif
79
+
75 80
 /*
76 81
  * Functions related to the translation of DNS names to IP addresses.
77 82
  */
... ...
@@ -2449,6 +2454,10 @@ link_socket_write_tcp(struct link_socket *sock, struct buffer *buf, struct link_
2449 2449
 #endif
2450 2450
 }
2451 2451
 
2452
+#if defined(__GNUC__) || defined(__clang__)
2453
+#pragma GCC diagnostic pop
2454
+#endif
2455
+
2452 2456
 #if ENABLE_IP_PKTINFO
2453 2457
 
2454 2458
 ssize_t
... ...
@@ -80,6 +80,11 @@ socks_proxy_close(struct socks_proxy_info *sp)
80 80
     free(sp);
81 81
 }
82 82
 
83
+#if defined(__GNUC__) || defined(__clang__)
84
+#pragma GCC diagnostic push
85
+#pragma GCC diagnostic ignored "-Wconversion"
86
+#endif
87
+
83 88
 static bool
84 89
 socks_proxy_recv_char(char *c, const char *name, socket_descriptor_t sd,
85 90
                       struct event_timeout *server_poll_timeout,
... ...
@@ -438,6 +443,10 @@ error:
438 438
     return;
439 439
 }
440 440
 
441
+#if defined(__GNUC__) || defined(__clang__)
442
+#pragma GCC diagnostic pop
443
+#endif
444
+
441 445
 void
442 446
 establish_socks_proxy_udpassoc(struct socks_proxy_info *p,
443 447
                                socket_descriptor_t ctrl_sd, /* already open to proxy */
... ...
@@ -180,6 +180,11 @@ tls_init_control_channel_frame_parameters(struct frame *frame, int tls_mtu)
180 180
     frame->tun_mtu = max_int(frame->tun_mtu, TLS_CHANNEL_MTU_MIN);
181 181
 }
182 182
 
183
+#if defined(__GNUC__) || defined(__clang__)
184
+#pragma GCC diagnostic push
185
+#pragma GCC diagnostic ignored "-Wconversion"
186
+#endif
187
+
183 188
 /**
184 189
  * calculate the maximum overhead that control channel frames have
185 190
  * This includes header, op code and everything apart from the
... ...
@@ -222,6 +227,10 @@ calc_control_channel_frame_overhead(const struct tls_session *session)
222 222
     return overhead;
223 223
 }
224 224
 
225
+#if defined(__GNUC__) || defined(__clang__)
226
+#pragma GCC diagnostic pop
227
+#endif
228
+
225 229
 void
226 230
 init_ssl_lib(void)
227 231
 {
... ...
@@ -1120,6 +1129,11 @@ compute_earliest_wakeup(interval_t *earliest, interval_t seconds_from_now)
1120 1120
     }
1121 1121
 }
1122 1122
 
1123
+#if defined(__GNUC__) || defined(__clang__)
1124
+#pragma GCC diagnostic push
1125
+#pragma GCC diagnostic ignored "-Wconversion"
1126
+#endif
1127
+
1123 1128
 /*
1124 1129
  * Return true if "lame duck" or retiring key has expired and can
1125 1130
  * no longer be used.
... ...
@@ -3979,6 +3993,10 @@ tls_prepend_opcode_v1(const struct tls_multi *multi, struct buffer *buf)
3979 3979
     ASSERT(buf_write_prepend(buf, &op, 1));
3980 3980
 }
3981 3981
 
3982
+#if defined(__GNUC__) || defined(__clang__)
3983
+#pragma GCC diagnostic pop
3984
+#endif
3985
+
3982 3986
 void
3983 3987
 tls_prepend_opcode_v2(const struct tls_multi *multi, struct buffer *buf)
3984 3988
 {
... ...
@@ -585,6 +585,11 @@ tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file, bool
585 585
     return 0;
586 586
 }
587 587
 
588
+#if defined(__GNUC__) || defined(__clang__)
589
+#pragma GCC diagnostic push
590
+#pragma GCC diagnostic ignored "-Wconversion"
591
+#endif
592
+
588 593
 /**
589 594
  * external_pkcs1_sign implements a mbed TLS rsa_sign_func callback, that uses
590 595
  * the management interface to request an RSA signature for the supplied hash.
... ...
@@ -1004,6 +1009,10 @@ tls_ctx_personalise_random(struct tls_root_ctx *ctx)
1004 1004
     }
1005 1005
 }
1006 1006
 
1007
+#if defined(__GNUC__) || defined(__clang__)
1008
+#pragma GCC diagnostic pop
1009
+#endif
1010
+
1007 1011
 int
1008 1012
 tls_version_max(void)
1009 1013
 {
... ...
@@ -534,6 +534,11 @@ check_session_cipher(struct tls_session *session, struct options *options)
534 534
     }
535 535
 }
536 536
 
537
+#if defined(__GNUC__) || defined(__clang__)
538
+#pragma GCC diagnostic push
539
+#pragma GCC diagnostic ignored "-Wconversion"
540
+#endif
541
+
537 542
 /**
538 543
  * Replaces the string DEFAULT with the string \c replace.
539 544
  *
... ...
@@ -566,6 +571,10 @@ replace_default_in_ncp_ciphers_option(struct options *o, const char *replace)
566 566
     o->ncp_ciphers = (char *)ncp_ciphers;
567 567
 }
568 568
 
569
+#if defined(__GNUC__) || defined(__clang__)
570
+#pragma GCC diagnostic pop
571
+#endif
572
+
569 573
 /**
570 574
  * Checks for availibility of Chacha20-Poly1305 and sets
571 575
  * the ncp_cipher to either AES-256-GCM:AES-128-GCM or
... ...
@@ -272,6 +272,11 @@ openssl_tls_version(int ver)
272 272
     return 0;
273 273
 }
274 274
 
275
+#if defined(__GNUC__) || defined(__clang__)
276
+#pragma GCC diagnostic push
277
+#pragma GCC diagnostic ignored "-Wconversion"
278
+#endif
279
+
275 280
 static bool
276 281
 tls_ctx_set_tls_versions(struct tls_root_ctx *ctx, unsigned int ssl_flags)
277 282
 {
... ...
@@ -424,6 +429,10 @@ convert_tls_list_to_openssl(char *openssl_ciphers, size_t len, const char *ciphe
424 424
     }
425 425
 }
426 426
 
427
+#if defined(__GNUC__) || defined(__clang__)
428
+#pragma GCC diagnostic pop
429
+#endif
430
+
427 431
 void
428 432
 tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
429 433
 {
... ...
@@ -2513,6 +2522,11 @@ print_details(struct key_state_ssl *ks_ssl, const char *prefix)
2513 2513
     msg(D_HANDSHAKE, "%s%s%s%s%s", s1, s2, s3, s4, s5);
2514 2514
 }
2515 2515
 
2516
+#if defined(__GNUC__) || defined(__clang__)
2517
+#pragma GCC diagnostic push
2518
+#pragma GCC diagnostic ignored "-Wconversion"
2519
+#endif
2520
+
2516 2521
 void
2517 2522
 show_available_tls_ciphers_list(const char *cipher_list, const char *tls_cert_profile, bool tls13)
2518 2523
 {
... ...
@@ -2580,6 +2594,10 @@ show_available_tls_ciphers_list(const char *cipher_list, const char *tls_cert_pr
2580 2580
     SSL_CTX_free(tls_ctx.ctx);
2581 2581
 }
2582 2582
 
2583
+#if defined(__GNUC__) || defined(__clang__)
2584
+#pragma GCC diagnostic pop
2585
+#endif
2586
+
2583 2587
 /*
2584 2588
  * Show the Elliptic curves that are available for us to use
2585 2589
  * in the OpenSSL library.
... ...
@@ -160,6 +160,11 @@ tls_wrap_control(struct tls_wrap_ctx *ctx, uint8_t header, struct buffer *buf,
160 160
     }
161 161
 }
162 162
 
163
+#if defined(__GNUC__) || defined(__clang__)
164
+#pragma GCC diagnostic push
165
+#pragma GCC diagnostic ignored "-Wconversion"
166
+#endif
167
+
163 168
 void
164 169
 write_control_auth(struct tls_session *session, struct key_state *ks, struct buffer *buf,
165 170
                    struct link_socket_actual **to_link_addr, int opcode, int max_ack,
... ...
@@ -495,6 +500,10 @@ calculate_session_id_hmac(struct session_id client_sid, const struct openvpn_soc
495 495
     return result.sid;
496 496
 }
497 497
 
498
+#if defined(__GNUC__) || defined(__clang__)
499
+#pragma GCC diagnostic pop
500
+#endif
501
+
498 502
 bool
499 503
 check_session_hmac_and_pkt_id(struct tls_pre_decrypt_state *state,
500 504
                               const struct openvpn_sockaddr *from,
... ...
@@ -290,6 +290,11 @@ tls_get_cipher_name_pair(const char *cipher_name, size_t len)
290 290
     return NULL;
291 291
 }
292 292
 
293
+#if defined(__GNUC__) || defined(__clang__)
294
+#pragma GCC diagnostic push
295
+#pragma GCC diagnostic ignored "-Wconversion"
296
+#endif
297
+
293 298
 int
294 299
 get_num_elements(const char *string, char delimiter)
295 300
 {
... ...
@@ -309,3 +314,7 @@ get_num_elements(const char *string, char delimiter)
309 309
 
310 310
     return element_count;
311 311
 }
312
+
313
+#if defined(__GNUC__) || defined(__clang__)
314
+#pragma GCC diagnostic pop
315
+#endif
... ...
@@ -874,6 +874,11 @@ check_auth_pending_method(const char *peer_info, const char *method)
874 874
     return supported;
875 875
 }
876 876
 
877
+#if defined(__GNUC__) || defined(__clang__)
878
+#pragma GCC diagnostic push
879
+#pragma GCC diagnostic ignored "-Wconversion"
880
+#endif
881
+
877 882
 /**
878 883
  *  Checks if the deferred state should also send auth pending
879 884
  *  request to the client. Also removes the auth_pending control file
... ...
@@ -945,6 +950,9 @@ key_state_check_auth_pending_file(struct auth_deferred_status *ads, struct tls_m
945 945
     return ret;
946 946
 }
947 947
 
948
+#if defined(__GNUC__) || defined(__clang__)
949
+#pragma GCC diagnostic pop
950
+#endif
948 951
 
949 952
 /**
950 953
  *  Removes auth_pending and auth_control files from file system
... ...
@@ -250,6 +250,11 @@ err:
250 250
     return FAILURE;
251 251
 }
252 252
 
253
+#if defined(__GNUC__) || defined(__clang__)
254
+#pragma GCC diagnostic push
255
+#pragma GCC diagnostic ignored "-Wconversion"
256
+#endif
257
+
253 258
 static struct buffer
254 259
 x509_get_fingerprint(const mbedtls_md_info_t *md_info, mbedtls_x509_crt *cert, struct gc_arena *gc)
255 260
 {
... ...
@@ -260,6 +265,10 @@ x509_get_fingerprint(const mbedtls_md_info_t *md_info, mbedtls_x509_crt *cert, s
260 260
     return fingerprint;
261 261
 }
262 262
 
263
+#if defined(__GNUC__) || defined(__clang__)
264
+#pragma GCC diagnostic pop
265
+#endif
266
+
263 267
 struct buffer
264 268
 x509_get_sha1_fingerprint(mbedtls_x509_crt *cert, struct gc_arena *gc)
265 269
 {
... ...
@@ -667,6 +667,11 @@ x509_verify_ns_cert_type(openvpn_x509_cert_t *peer_cert, const int usage)
667 667
     return FAILURE;
668 668
 }
669 669
 
670
+#if defined(__GNUC__) || defined(__clang__)
671
+#pragma GCC diagnostic push
672
+#pragma GCC diagnostic ignored "-Wconversion"
673
+#endif
674
+
670 675
 result_t
671 676
 x509_verify_cert_ku(X509 *x509, const unsigned *const expected_ku, int expected_len)
672 677
 {
... ...
@@ -726,6 +731,10 @@ x509_verify_cert_ku(X509 *x509, const unsigned *const expected_ku, int expected_
726 726
     return fFound;
727 727
 }
728 728
 
729
+#if defined(__GNUC__) || defined(__clang__)
730
+#pragma GCC diagnostic pop
731
+#endif
732
+
729 733
 result_t
730 734
 x509_verify_cert_eku(X509 *x509, const char *const expected_oid)
731 735
 {
... ...
@@ -207,6 +207,11 @@ status_close(struct status_output *so)
207 207
     return ret;
208 208
 }
209 209
 
210
+#if defined(__GNUC__) || defined(__clang__)
211
+#pragma GCC diagnostic push
212
+#pragma GCC diagnostic ignored "-Wconversion"
213
+#endif
214
+
210 215
 #define STATUS_PRINTF_MAXLEN 512
211 216
 
212 217
 void
... ...
@@ -303,3 +308,7 @@ status_read(struct status_output *so, struct buffer *buf)
303 303
 
304 304
     return ret;
305 305
 }
306
+
307
+#if defined(__GNUC__) || defined(__clang__)
308
+#pragma GCC diagnostic pop
309
+#endif
... ...
@@ -205,6 +205,11 @@ err:
205 205
     return false;
206 206
 }
207 207
 
208
+#if defined(__GNUC__) || defined(__clang__)
209
+#pragma GCC diagnostic push
210
+#pragma GCC diagnostic ignored "-Wconversion"
211
+#endif
212
+
208 213
 bool
209 214
 tls_crypt_unwrap(const struct buffer *src, struct buffer *dst, struct crypto_options *opt)
210 215
 {
... ...
@@ -413,6 +418,10 @@ tls_crypt_v2_wrap_client_key(struct buffer *wkc, const struct key2 *src_key,
413 413
     return buf_copy(wkc, &work);
414 414
 }
415 415
 
416
+#if defined(__GNUC__) || defined(__clang__)
417
+#pragma GCC diagnostic pop
418
+#endif
419
+
416 420
 static bool
417 421
 tls_crypt_v2_unwrap_client_key(struct key2 *client_key, struct buffer *metadata,
418 422
                                struct buffer wrapped_client_key, struct key_ctx *server_key)
... ...
@@ -1720,6 +1720,11 @@ header_modify_read_write_return(int len)
1720 1720
     }
1721 1721
 }
1722 1722
 
1723
+#if defined(__GNUC__) || defined(__clang__)
1724
+#pragma GCC diagnostic push
1725
+#pragma GCC diagnostic ignored "-Wconversion"
1726
+#endif
1727
+
1723 1728
 static int
1724 1729
 write_tun_header(struct tuntap *tt, uint8_t *buf, int len)
1725 1730
 {
... ...
@@ -1773,6 +1778,11 @@ read_tun_header(struct tuntap *tt, uint8_t *buf, int len)
1773 1773
         return read(tt->fd, buf, len);
1774 1774
     }
1775 1775
 }
1776
+
1777
+#if defined(__GNUC__) || defined(__clang__)
1778
+#pragma GCC diagnostic pop
1779
+#endif
1780
+
1776 1781
 #endif /* if defined (TARGET_OPENBSD) || defined(TARGET_DARWIN) */
1777 1782
 
1778 1783
 bool
... ...
@@ -2244,6 +2254,11 @@ close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx)
2244 2244
     free(tt);
2245 2245
 }
2246 2246
 
2247
+#if defined(__GNUC__) || defined(__clang__)
2248
+#pragma GCC diagnostic push
2249
+#pragma GCC diagnostic ignored "-Wconversion"
2250
+#endif
2251
+
2247 2252
 int
2248 2253
 write_tun(struct tuntap *tt, uint8_t *buf, int len)
2249 2254
 {
... ...
@@ -2256,6 +2271,10 @@ read_tun(struct tuntap *tt, uint8_t *buf, int len)
2256 2256
     return read(tt->fd, buf, len);
2257 2257
 }
2258 2258
 
2259
+#if defined(__GNUC__) || defined(__clang__)
2260
+#pragma GCC diagnostic pop
2261
+#endif
2262
+
2259 2263
 #elif defined(TARGET_SOLARIS)
2260 2264
 
2261 2265
 #ifndef TUNNEWPPA
... ...
@@ -2935,6 +2954,11 @@ close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx)
2935 2935
     argv_free(&argv);
2936 2936
 }
2937 2937
 
2938
+#if defined(__GNUC__) || defined(__clang__)
2939
+#pragma GCC diagnostic push
2940
+#pragma GCC diagnostic ignored "-Wconversion"
2941
+#endif
2942
+
2938 2943
 int
2939 2944
 write_tun(struct tuntap *tt, uint8_t *buf, int len)
2940 2945
 {
... ...
@@ -2989,6 +3013,10 @@ read_tun(struct tuntap *tt, uint8_t *buf, int len)
2989 2989
     }
2990 2990
 }
2991 2991
 
2992
+#if defined(__GNUC__) || defined(__clang__)
2993
+#pragma GCC diagnostic pop
2994
+#endif
2995
+
2992 2996
 #elif defined(TARGET_DRAGONFLY)
2993 2997
 
2994 2998
 static inline int
... ...
@@ -3277,6 +3305,11 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
3277 3277
     }
3278 3278
 }
3279 3279
 
3280
+#if defined(__GNUC__) || defined(__clang__)
3281
+#pragma GCC diagnostic push
3282
+#pragma GCC diagnostic ignored "-Wconversion"
3283
+#endif
3284
+
3280 3285
 void
3281 3286
 close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx)
3282 3287
 {
... ...
@@ -3326,6 +3359,10 @@ read_tun(struct tuntap *tt, uint8_t *buf, int len)
3326 3326
     }
3327 3327
 }
3328 3328
 
3329
+#if defined(__GNUC__) || defined(__clang__)
3330
+#pragma GCC diagnostic pop
3331
+#endif
3332
+
3329 3333
 #elif defined(TARGET_AIX)
3330 3334
 
3331 3335
 void
... ...
@@ -5517,6 +5554,11 @@ tun_standby(struct tuntap *tt)
5517 5517
     return ret;
5518 5518
 }
5519 5519
 
5520
+#if defined(__GNUC__) || defined(__clang__)
5521
+#pragma GCC diagnostic push
5522
+#pragma GCC diagnostic ignored "-Wconversion"
5523
+#endif
5524
+
5520 5525
 /*
5521 5526
  * Convert DHCP options from the command line / config file
5522 5527
  * into a raw DHCP-format options string.
... ...
@@ -5656,6 +5698,10 @@ write_dhcp_search_str(struct buffer *buf, const int type, const char *const *str
5656 5656
     buf_write(buf, tmp_buf, len);
5657 5657
 }
5658 5658
 
5659
+#if defined(__GNUC__) || defined(__clang__)
5660
+#pragma GCC diagnostic pop
5661
+#endif
5662
+
5659 5663
 static bool
5660 5664
 build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o)
5661 5665
 {
... ...
@@ -43,6 +43,11 @@ vlanhdr_get_vid(const struct openvpn_8021qhdr *hdr)
43 43
     return ntohs(hdr->pcp_cfi_vid & OPENVPN_8021Q_MASK_VID);
44 44
 }
45 45
 
46
+#if defined(__GNUC__) || defined(__clang__)
47
+#pragma GCC diagnostic push
48
+#pragma GCC diagnostic ignored "-Wconversion"
49
+#endif
50
+
46 51
 /*
47 52
  * Set the VLAN Identifier (VID) in an IEEE 802.1Q header.
48 53
  *
... ...
@@ -56,6 +61,10 @@ vlanhdr_set_vid(struct openvpn_8021qhdr *hdr, const uint16_t vid)
56 56
         (hdr->pcp_cfi_vid & ~OPENVPN_8021Q_MASK_VID) | (htons(vid) & OPENVPN_8021Q_MASK_VID);
57 57
 }
58 58
 
59
+#if defined(__GNUC__) || defined(__clang__)
60
+#pragma GCC diagnostic pop
61
+#endif
62
+
59 63
 /*
60 64
  * vlan_decapsulate - remove 802.1q header and return VID
61 65
  *
... ...
@@ -1418,6 +1418,11 @@ win32_version_string(struct gc_arena *gc)
1418 1418
     return (const char *)out.data;
1419 1419
 }
1420 1420
 
1421
+#if defined(__GNUC__) || defined(__clang__)
1422
+#pragma GCC diagnostic push
1423
+#pragma GCC diagnostic ignored "-Wconversion"
1424
+#endif
1425
+
1421 1426
 bool
1422 1427
 send_msg_iservice(HANDLE pipe, const void *data, size_t size, ack_message_t *ack,
1423 1428
                   const char *context)
... ...
@@ -1632,4 +1637,8 @@ unprotect_buffer_win32(char *buf, size_t len)
1632 1632
     return ret;
1633 1633
 }
1634 1634
 
1635
+#if defined(__GNUC__) || defined(__clang__)
1636
+#pragma GCC diagnostic pop
1637
+#endif
1638
+
1635 1639
 #endif /* ifdef _WIN32 */
... ...
@@ -1383,6 +1383,11 @@ InitialSearchListExists(HKEY key)
1383 1383
     return TRUE;
1384 1384
 }
1385 1385
 
1386
+#if defined(__GNUC__) || defined(__clang__)
1387
+#pragma GCC diagnostic push
1388
+#pragma GCC diagnostic ignored "-Wconversion"
1389
+#endif
1390
+
1386 1391
 /**
1387 1392
  * Prepare DNS domain "SearchList" registry value, so additional
1388 1393
  * VPN domains can be added and its original state can be restored
... ...
@@ -2614,6 +2619,10 @@ SetNrptRules(HKEY nrpt_key, const nrpt_address_t *addresses, const char *domains
2614 2614
     return err;
2615 2615
 }
2616 2616
 
2617
+#if defined(__GNUC__) || defined(__clang__)
2618
+#pragma GCC diagnostic pop
2619
+#endif
2620
+
2617 2621
 /**
2618 2622
  * Return the registry key where NRPT rules are stored
2619 2623
  *
... ...
@@ -674,6 +674,11 @@ struct epoch_test_state
674 674
     struct crypto_options co;
675 675
 };
676 676
 
677
+#if defined(__GNUC__) || defined(__clang__)
678
+#pragma GCC diagnostic push
679
+#pragma GCC diagnostic ignored "-Wconversion"
680
+#endif
681
+
677 682
 static int
678 683
 crypto_test_epoch_setup(void **state)
679 684
 {
... ...
@@ -694,6 +699,10 @@ crypto_test_epoch_setup(void **state)
694 694
     return 0;
695 695
 }
696 696
 
697
+#if defined(__GNUC__) || defined(__clang__)
698
+#pragma GCC diagnostic pop
699
+#endif
700
+
697 701
 static int
698 702
 crypto_test_epoch_teardown(void **state)
699 703
 {
... ...
@@ -378,7 +378,7 @@ test_pkcs11_ids(void **state)
378 378
         /* decode the base64 data and convert to X509 and get its sha1 fingerprint */
379 379
         unsigned char *der = malloc(strlen(base64));
380 380
         assert_non_null(der);
381
-        int derlen = openvpn_base64_decode(base64, der, strlen(base64));
381
+        int derlen = openvpn_base64_decode(base64, der, (int)strlen(base64));
382 382
         free(base64);
383 383
         assert_true(derlen > 0);
384 384
 
... ...
@@ -133,6 +133,11 @@ static struct
133 133
     const char *keyfile;
134 134
 } global_state;
135 135
 
136
+#if defined(__GNUC__) || defined(__clang__)
137
+#pragma GCC diagnostic push
138
+#pragma GCC diagnostic ignored "-Wconversion"
139
+#endif
140
+
136 141
 static int
137 142
 init(void **state)
138 143
 {
... ...
@@ -154,6 +159,10 @@ init(void **state)
154 154
     return 0;
155 155
 }
156 156
 
157
+#if defined(__GNUC__) || defined(__clang__)
158
+#pragma GCC diagnostic pop
159
+#endif
160
+
157 161
 static int
158 162
 cleanup(void **state)
159 163
 {