Browse code

More broadly enforce Allman style and braces-around-conditionals

We want { and } aligned, which means also adding a newline between each
for() and {, while() and {, etc.

Also, we agreed to always use braces with conditionals. The previous
uncrustify config added these for if()s, now also add these for while()
and for().

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1484403020-6857-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13875.html
Signed-off-by: David Sommerseth <davids@openvpn.net>

Steffan Karger authored on 2017/01/14 23:10:20
Showing 69 changed files
... ...
@@ -9,6 +9,11 @@ nl_brace_else=add
9 9
 nl_elseif_brace=add
10 10
 nl_else_brace=add
11 11
 nl_else_if=remove
12
+nl_for_brace=add
13
+nl_while_brace=add
14
+nl_switch_brace=add
15
+nl_fdef_brace=add
16
+nl_do_brace=add
12 17
 sp_func_proto_paren=Remove
13 18
 sp_func_def_paren=Remove
14 19
 sp_func_call_paren=Remove
... ...
@@ -44,6 +49,9 @@ nl_after_func_proto=2
44 44
 # Always use scoping braces for conditionals
45 45
 mod_full_brace_if=add
46 46
 mod_full_brace_if_chain=false
47
+mod_full_brace_while=add
48
+mod_full_brace_for=add
49
+mod_full_brace_do=add
47 50
 
48 51
 # Annotate #else and #endif statements
49 52
 mod_add_long_ifdef_endif_comment=20
... ...
@@ -58,7 +58,8 @@ int
58 58
 daemon(int nochdir, int noclose)
59 59
 {
60 60
 #if defined(HAVE_FORK) && defined(HAVE_SETSID)
61
-    switch (fork()) {
61
+    switch (fork())
62
+    {
62 63
         case -1:
63 64
             return (-1);
64 65
 
... ...
@@ -44,7 +44,8 @@ __memrchr(const char *str, int c, size_t n)
44 44
     const char *end = str;
45 45
 
46 46
     end += n - 1; /* Go to the end of the string */
47
-    while (end >= str) {
47
+    while (end >= str)
48
+    {
48 49
         if (c == *end)
49 50
         {
50 51
             return end;
... ...
@@ -82,10 +83,12 @@ dirname(char *path)
82 82
         char *runp;
83 83
 
84 84
         for (runp = last_slash; runp != path; --runp)
85
+        {
85 86
             if (runp[-1] != separator)
86 87
             {
87 88
                 break;
88 89
             }
90
+        }
89 91
 
90 92
         /* The '/' is the last character, we have to look further.  */
91 93
         if (runp != path)
... ...
@@ -100,10 +103,12 @@ dirname(char *path)
100 100
         char *runp;
101 101
 
102 102
         for (runp = last_slash; runp != path; --runp)
103
+        {
103 104
             if (runp[-1] != separator)
104 105
             {
105 106
                 break;
106 107
             }
108
+        }
107 109
 
108 110
         /* Terminate the path.  */
109 111
         if (runp == path)
... ...
@@ -52,7 +52,8 @@ inet_ntop(int af, const void *src, char *dst, socklen_t size)
52 52
     ZeroMemory(&ss, sizeof(ss));
53 53
     ss.ss_family = af;
54 54
 
55
-    switch (af) {
55
+    switch (af)
56
+    {
56 57
         case AF_INET:
57 58
             ((struct sockaddr_in *)&ss)->sin_addr = *(struct in_addr *)src;
58 59
             break;
... ...
@@ -59,7 +59,8 @@ inet_pton(int af, const char *src, void *dst)
59 59
 
60 60
     if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0)
61 61
     {
62
-        switch (af) {
62
+        switch (af)
63
+        {
63 64
             case AF_INET:
64 65
                 *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
65 66
                 return 1;
... ...
@@ -30,62 +30,74 @@ IsWindowsVersionOrGreater(WORD major, WORD minor, WORD servpack)
30 30
 }
31 31
 
32 32
 VERSIONHELPERAPI
33
-IsWindowsXPOrGreater(void) {
33
+IsWindowsXPOrGreater(void)
34
+{
34 35
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
35 36
 }
36 37
 
37 38
 VERSIONHELPERAPI
38
-IsWindowsXPSP1OrGreater(void) {
39
+IsWindowsXPSP1OrGreater(void)
40
+{
39 41
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1);
40 42
 }
41 43
 
42 44
 VERSIONHELPERAPI
43
-IsWindowsXPSP2OrGreater(void) {
45
+IsWindowsXPSP2OrGreater(void)
46
+{
44 47
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2);
45 48
 }
46 49
 
47 50
 VERSIONHELPERAPI
48
-IsWindowsXPSP3OrGreater(void) {
51
+IsWindowsXPSP3OrGreater(void)
52
+{
49 53
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3);
50 54
 }
51 55
 
52 56
 VERSIONHELPERAPI
53
-IsWindowsVistaOrGreater(void) {
57
+IsWindowsVistaOrGreater(void)
58
+{
54 59
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
55 60
 }
56 61
 
57 62
 VERSIONHELPERAPI
58
-IsWindowsVistaSP1OrGreater(void) {
63
+IsWindowsVistaSP1OrGreater(void)
64
+{
59 65
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1);
60 66
 }
61 67
 
62 68
 VERSIONHELPERAPI
63
-IsWindowsVistaSP2OrGreater(void) {
69
+IsWindowsVistaSP2OrGreater(void)
70
+{
64 71
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2);
65 72
 }
66 73
 
67 74
 VERSIONHELPERAPI
68
-IsWindows7OrGreater(void) {
75
+IsWindows7OrGreater(void)
76
+{
69 77
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
70 78
 }
71 79
 
72 80
 VERSIONHELPERAPI
73
-IsWindows7SP1OrGreater(void) {
81
+IsWindows7SP1OrGreater(void)
82
+{
74 83
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1);
75 84
 }
76 85
 
77 86
 VERSIONHELPERAPI
78
-IsWindows8OrGreater(void) {
87
+IsWindows8OrGreater(void)
88
+{
79 89
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
80 90
 }
81 91
 
82 92
 VERSIONHELPERAPI
83
-IsWindows8Point1OrGreater(void) {
93
+IsWindows8Point1OrGreater(void)
94
+{
84 95
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
85 96
 }
86 97
 
87 98
 VERSIONHELPERAPI
88
-IsWindowsServer(void) {
99
+IsWindowsServer(void)
100
+{
89 101
     OSVERSIONINFOEXW vi = {sizeof(vi),0,0,0,0,{0},0,0,0,VER_NT_WORKSTATION};
90 102
     return !VerifyVersionInfoW(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
91 103
 }
... ...
@@ -60,7 +60,9 @@ argv_reset(struct argv *a)
60 60
 {
61 61
     size_t i;
62 62
     for (i = 0; i < a->argc; ++i)
63
+    {
63 64
         free(a->argv[i]);
65
+    }
64 66
     free(a->argv);
65 67
     argv_init(a);
66 68
 }
... ...
@@ -74,7 +76,9 @@ argv_extend(struct argv *a, const size_t newcap)
74 74
         size_t i;
75 75
         ALLOC_ARRAY_CLEAR(newargv, char *, newcap);
76 76
         for (i = 0; i < a->argc; ++i)
77
+        {
77 78
             newargv[i] = a->argv[i];
79
+        }
78 80
         free(a->argv);
79 81
         a->argv = newargv;
80 82
         a->capacity = newcap;
... ...
@@ -104,11 +108,15 @@ argv_clone(const struct argv *a, const size_t headroom)
104 104
 
105 105
     argv_init(&r);
106 106
     for (i = 0; i < headroom; ++i)
107
+    {
107 108
         argv_append(&r, NULL);
109
+    }
108 110
     if (a)
109 111
     {
110 112
         for (i = 0; i < a->argc; ++i)
113
+        {
111 114
             argv_append(&r, string_alloc(a->argv[i], NULL));
115
+        }
112 116
     }
113 117
     return r;
114 118
 }
... ...
@@ -332,7 +340,9 @@ argv_parse_cmd(struct argv *a, const char *s)
332 332
     {
333 333
         int i;
334 334
         for (i = 0; i < nparms; ++i)
335
+        {
335 336
             argv_append(a, string_alloc(parms[i], NULL));
337
+        }
336 338
     }
337 339
     else
338 340
     {
... ...
@@ -69,7 +69,8 @@ openvpn_base64_encode(const void *data, int size, char **str)
69 69
     }
70 70
     q = (const unsigned char *) data;
71 71
     i = 0;
72
-    for (i = 0; i < size; ) {
72
+    for (i = 0; i < size; )
73
+    {
73 74
         c = q[i++];
74 75
         c *= 256;
75 76
         if (i < size)
... ...
@@ -107,10 +108,12 @@ pos(char c)
107 107
 {
108 108
     char *p;
109 109
     for (p = base64_chars; *p; p++)
110
+    {
110 111
         if (*p == c)
111 112
         {
112 113
             return p - base64_chars;
113 114
         }
115
+    }
114 116
     return -1;
115 117
 }
116 118
 
... ...
@@ -126,7 +129,8 @@ token_decode(const char *token)
126 126
     {
127 127
         return DECODE_ERROR;
128 128
     }
129
-    for (i = 0; i < 4; i++) {
129
+    for (i = 0; i < 4; i++)
130
+    {
130 131
         val *= 64;
131 132
         if (token[i] == '=')
132 133
         {
... ...
@@ -164,7 +168,8 @@ openvpn_base64_decode(const char *str, void *data, int size)
164 164
     {
165 165
         e = q + size;
166 166
     }
167
-    for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4) {
167
+    for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4)
168
+    {
168 169
         unsigned int val = token_decode(p);
169 170
         unsigned int marker = (val >> 24) & 0xff;
170 171
         if (val == DECODE_ERROR)
... ...
@@ -443,7 +443,9 @@ gc_transfer(struct gc_arena *dest, struct gc_arena *src)
443 443
         if (e)
444 444
         {
445 445
             while (e->next != NULL)
446
+            {
446 447
                 e = e->next;
448
+            }
447 449
             e->next = dest->list;
448 450
             dest->list = src->list;
449 451
             src->list = NULL;
... ...
@@ -599,7 +601,8 @@ void
599 599
 rm_trailing_chars(char *str, const char *what_to_delete)
600 600
 {
601 601
     bool modified;
602
-    do {
602
+    do
603
+    {
603 604
         const int len = strlen(str);
604 605
         modified = false;
605 606
         if (len > 0)
... ...
@@ -682,7 +685,9 @@ string_array_len(const char **array)
682 682
     if (array)
683 683
     {
684 684
         while (array[i])
685
+        {
685 686
             ++i;
687
+        }
686 688
     }
687 689
     return i;
688 690
 }
... ...
@@ -1320,7 +1325,9 @@ buffer_list_file(const char *fn, int max_line_len)
1320 1320
         {
1321 1321
             bl = buffer_list_new(0);
1322 1322
             while (fgets(line, max_line_len, fp) != NULL)
1323
+            {
1323 1324
                 buffer_list_push(bl, (unsigned char *)line);
1325
+            }
1324 1326
             free(line);
1325 1327
         }
1326 1328
         fclose(fp);
... ...
@@ -404,7 +404,9 @@ secure_memzero(void *data, size_t len)
404 404
 #else
405 405
     volatile char *p = (volatile char *) data;
406 406
     while (len--)
407
+    {
407 408
         *p++ = 0;
409
+    }
408 410
 #endif
409 411
 }
410 412
 
... ...
@@ -316,6 +316,7 @@ const struct compress_alg lz4v2_alg = {
316 316
 
317 317
 #else  /* if defined(ENABLE_LZ4) */
318 318
 static void
319
-dummy(void) {
319
+dummy(void)
320
+{
320 321
 }
321 322
 #endif /* ENABLE_LZ4 */
... ...
@@ -179,6 +179,7 @@ const struct compress_alg comp_stub_alg = {
179 179
 
180 180
 #else  /* if defined(USE_COMP) */
181 181
 static void
182
-dummy(void) {
182
+dummy(void)
183
+{
183 184
 }
184 185
 #endif /* USE_STUB */
... ...
@@ -49,7 +49,8 @@ query_user_clear()
49 49
 {
50 50
     int i;
51 51
 
52
-    for (i = 0; i < QUERY_USER_NUMSLOTS; i++) {
52
+    for (i = 0; i < QUERY_USER_NUMSLOTS; i++)
53
+    {
53 54
         CLEAR(query_user[i]);
54 55
     }
55 56
 }
... ...
@@ -68,7 +69,8 @@ query_user_add(char *prompt, size_t prompt_len,
68 68
     ASSERT( prompt_len > 0 && prompt != NULL && resp_len > 0 && resp != NULL );
69 69
 
70 70
     /* Seek to the last unused slot */
71
-    for (i = 0; i < QUERY_USER_NUMSLOTS; i++) {
71
+    for (i = 0; i < QUERY_USER_NUMSLOTS; i++)
72
+    {
72 73
         if (query_user[i].prompt == NULL)
73 74
         {
74 75
             break;
... ...
@@ -65,7 +65,8 @@
65 65
 
66 66
 static void
67 67
 openvpn_encrypt_aead(struct buffer *buf, struct buffer work,
68
-                     struct crypto_options *opt) {
68
+                     struct crypto_options *opt)
69
+{
69 70
 #ifdef HAVE_AEAD_CIPHER_MODES
70 71
     struct gc_arena gc;
71 72
     int outlen = 0;
... ...
@@ -321,7 +322,8 @@ openvpn_encrypt(struct buffer *buf, struct buffer work,
321 321
 bool
322 322
 crypto_check_replay(struct crypto_options *opt,
323 323
                     const struct packet_id_net *pin, const char *error_prefix,
324
-                    struct gc_arena *gc) {
324
+                    struct gc_arena *gc)
325
+{
325 326
     bool ret = false;
326 327
     packet_id_reap_test(&opt->packet_id.rec);
327 328
     if (packet_id_test(&opt->packet_id.rec, pin))
... ...
@@ -996,7 +998,8 @@ generate_key_random(struct key *key, const struct key_type *kt)
996 996
 
997 997
     struct gc_arena gc = gc_new();
998 998
 
999
-    do {
999
+    do
1000
+    {
1000 1001
         CLEAR(*key);
1001 1002
         if (kt)
1002 1003
         {
... ...
@@ -1772,7 +1775,8 @@ get_random()
1772 1772
 }
1773 1773
 
1774 1774
 static const cipher_name_pair *
1775
-get_cipher_name_pair(const char *cipher_name) {
1775
+get_cipher_name_pair(const char *cipher_name)
1776
+{
1776 1777
     const cipher_name_pair *pair;
1777 1778
     size_t i = 0;
1778 1779
 
... ...
@@ -1792,7 +1796,8 @@ get_cipher_name_pair(const char *cipher_name) {
1792 1792
 }
1793 1793
 
1794 1794
 const char *
1795
-translate_cipher_name_from_openvpn(const char *cipher_name) {
1795
+translate_cipher_name_from_openvpn(const char *cipher_name)
1796
+{
1796 1797
     const cipher_name_pair *pair = get_cipher_name_pair(cipher_name);
1797 1798
 
1798 1799
     if (NULL == pair)
... ...
@@ -1804,7 +1809,8 @@ translate_cipher_name_from_openvpn(const char *cipher_name) {
1804 1804
 }
1805 1805
 
1806 1806
 const char *
1807
-translate_cipher_name_to_openvpn(const char *cipher_name) {
1807
+translate_cipher_name_to_openvpn(const char *cipher_name)
1808
+{
1808 1809
     const cipher_name_pair *pair = get_cipher_name_pair(cipher_name);
1809 1810
 
1810 1811
     if (NULL == pair)
... ...
@@ -490,7 +490,8 @@ void crypto_read_openvpn_key(const struct key_type *key_type,
490 490
  * Returns 0 when data is equal, non-zero otherwise.
491 491
  */
492 492
 static inline int
493
-memcmp_constant_time(const void *a, const void *b, size_t size) {
493
+memcmp_constant_time(const void *a, const void *b, size_t size)
494
+{
494 495
     const uint8_t *a1 = a;
495 496
     const uint8_t *b1 = b;
496 497
     int ret = 0;
... ...
@@ -122,7 +122,8 @@ bool mbed_log_func_line(unsigned int flags, int errval, const char *func,
122 122
 /** Wraps mbed_log_func_line() to prevent function calls for non-errors */
123 123
 static inline bool
124 124
 mbed_log_func_line_lite(unsigned int flags, int errval,
125
-                        const char *func, int line) {
125
+                        const char *func, int line)
126
+{
126 127
     if (errval)
127 128
     {
128 129
         return mbed_log_func_line(flags, errval, func, line);
... ...
@@ -186,7 +186,8 @@ crypto_clear_error(void)
186 186
 }
187 187
 
188 188
 void
189
-crypto_print_openssl_errors(const unsigned int flags) {
189
+crypto_print_openssl_errors(const unsigned int flags)
190
+{
190 191
     size_t err = 0;
191 192
 
192 193
     while ((err = ERR_get_error()))
... ...
@@ -551,8 +552,10 @@ cipher_kt_iv_size(const EVP_CIPHER *cipher_kt)
551 551
 }
552 552
 
553 553
 int
554
-cipher_kt_block_size(const EVP_CIPHER *cipher) {
555
-    /* OpenSSL reports OFB/CFB/GCM cipher block sizes as '1 byte'.  To work
554
+cipher_kt_block_size(const EVP_CIPHER *cipher)
555
+{
556
+    /*
557
+     * OpenSSL reports OFB/CFB/GCM cipher block sizes as '1 byte'.  To work
556 558
      * around that, try to replace the mode with 'CBC' and return the block size
557 559
      * reported for that cipher, if possible.  If that doesn't work, just return
558 560
      * the value reported by OpenSSL.
... ...
@@ -281,7 +281,9 @@ rsa_priv_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, i
281 281
     }
282 282
     /* and now, we have to reverse the byte-order in the result from CryptSignHash()... */
283 283
     for (i = 0; i < len; i++)
284
+    {
284 285
         to[i] = buf[len - i - 1];
286
+    }
285 287
     free(buf);
286 288
 
287 289
     CryptDestroyHash(hash);
... ...
@@ -389,7 +391,9 @@ find_certificate_in_store(const char *cert_prop, HCERTSTORE cert_store)
389 389
             }
390 390
             hash[i] = x;
391 391
             /* skip any space(s) between hex numbers */
392
-            for (p++; *p && *p == ' '; p++) ;
392
+            for (p++; *p && *p == ' '; p++)
393
+            {
394
+            }
393 395
         }
394 396
         blob.cbData = i;
395 397
         blob.pbData = (unsigned char *) &hash;
... ...
@@ -547,7 +551,8 @@ err:
547 547
 #else  /* ifdef ENABLE_CRYPTOAPI */
548 548
 #ifdef _MSC_VER  /* Dummy function needed to avoid empty file compiler warning in Microsoft VC */
549 549
 static void
550
-dummy(void) {
550
+dummy(void)
551
+{
551 552
 }
552 553
 #endif
553 554
 #endif                          /* _WIN32 */
... ...
@@ -160,17 +160,20 @@ udp_checksum(const uint8_t *buf,
160 160
 
161 161
     /* make 16 bit words out of every two adjacent 8 bit words and  */
162 162
     /* calculate the sum of all 16 bit words */
163
-    for (i = 0; i < len_udp; i += 2) {
163
+    for (i = 0; i < len_udp; i += 2)
164
+    {
164 165
         word16 = ((buf[i] << 8) & 0xFF00) + ((i + 1 < len_udp) ? (buf[i+1] & 0xFF) : 0);
165 166
         sum += word16;
166 167
     }
167 168
 
168 169
     /* add the UDP pseudo header which contains the IP source and destination addresses */
169
-    for (i = 0; i < 4; i += 2) {
170
+    for (i = 0; i < 4; i += 2)
171
+    {
170 172
         word16 = ((src_addr[i] << 8) & 0xFF00) + (src_addr[i+1] & 0xFF);
171 173
         sum += word16;
172 174
     }
173
-    for (i = 0; i < 4; i += 2) {
175
+    for (i = 0; i < 4; i += 2)
176
+    {
174 177
         word16 = ((dest_addr[i] << 8) & 0xFF00) + (dest_addr[i+1] & 0xFF);
175 178
         sum += word16;
176 179
     }
... ...
@@ -180,7 +183,9 @@ udp_checksum(const uint8_t *buf,
180 180
 
181 181
     /* keep only the last 16 bits of the 32 bit calculated sum and add the carries */
182 182
     while (sum >> 16)
183
+    {
183 184
         sum = (sum & 0xFFFF) + (sum >> 16);
185
+    }
184 186
 
185 187
     /* Take the one's complement of sum */
186 188
     return ((uint16_t) ~sum);
... ...
@@ -836,7 +836,8 @@ strerror_win32(DWORD errnum, struct gc_arena *gc)
836 836
      * Posix equivalents.
837 837
      */
838 838
 #if 1
839
-    switch (errnum) {
839
+    switch (errnum)
840
+    {
840 841
         /*
841 842
          * When the TAP-Windows driver returns STATUS_UNSUCCESSFUL, this code
842 843
          * gets returned to user space.
... ...
@@ -394,7 +394,8 @@ ignore_sys_error(const int err)
394 394
 
395 395
 /** Convert fatal errors to nonfatal, don't touch other errors */
396 396
 static inline unsigned int
397
-nonfatal(const unsigned int err) {
397
+nonfatal(const unsigned int err)
398
+{
398 399
     return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err;
399 400
 }
400 401
 
... ...
@@ -394,11 +394,13 @@ we_wait(struct event_set *es, const struct timeval *tv, struct event_set_return
394 394
     {
395 395
         int i;
396 396
         for (i = 0; i < wes->n_events; ++i)
397
+        {
397 398
             dmsg(D_EVENT_WAIT, "[%d] ev=%p rwflags=0x%04x arg=" ptr_format,
398 399
                  i,
399 400
                  wes->events[i],
400 401
                  wes->esr[i].rwflags,
401 402
                  (ptr_type)wes->esr[i].arg);
403
+        }
402 404
     }
403 405
 #endif
404 406
 
... ...
@@ -922,7 +924,9 @@ se_reset(struct event_set *es)
922 922
     FD_ZERO(&ses->readfds);
923 923
     FD_ZERO(&ses->writefds);
924 924
     for (i = 0; i <= ses->maxfd; ++i)
925
+    {
925 926
         ses->args[i] = NULL;
927
+    }
926 928
     ses->maxfd = -1;
927 929
 }
928 930
 
... ...
@@ -44,7 +44,9 @@ fragment_list_buf_init(struct fragment_list *list, const struct frame *frame)
44 44
 {
45 45
     int i;
46 46
     for (i = 0; i < N_FRAG_BUF; ++i)
47
+    {
47 48
         list->fragments[i].buf = alloc_buf(BUF_SIZE(frame));
49
+    }
48 50
 }
49 51
 
50 52
 static void
... ...
@@ -52,7 +54,9 @@ fragment_list_buf_free(struct fragment_list *list)
52 52
 {
53 53
     int i;
54 54
     for (i = 0; i < N_FRAG_BUF; ++i)
55
+    {
55 56
         free_buf(&list->fragments[i].buf);
57
+    }
56 58
 }
57 59
 
58 60
 /*
... ...
@@ -67,7 +71,9 @@ fragment_list_get_buf(struct fragment_list *list, int seq_id)
67 67
     {
68 68
         int i;
69 69
         for (i = 0; i < N_FRAG_BUF; ++i)
70
+        {
70 71
             list->fragments[i].defined = false;
72
+        }
71 73
         list->index = 0;
72 74
         list->seq_id = seq_id;
73 75
         diff = 0;
... ...
@@ -433,6 +439,7 @@ fragment_wakeup(struct fragment_master *f, struct frame *frame)
433 433
 
434 434
 #else  /* ifdef ENABLE_FRAGMENT */
435 435
 static void
436
-dummy(void) {
436
+dummy(void)
437
+{
437 438
 }
438 439
 #endif /* ifdef ENABLE_FRAGMENT */
... ...
@@ -95,7 +95,8 @@ get_packet_flood_parms(int level)
95 95
  * Return true with probability 1/n
96 96
  */
97 97
 static bool
98
-flip(int n) {
98
+flip(int n)
99
+{
99 100
     return (get_random() % n) == 0;
100 101
 }
101 102
 
... ...
@@ -104,7 +105,8 @@ flip(int n) {
104 104
  * low and high.
105 105
  */
106 106
 static int
107
-roll(int low, int high) {
107
+roll(int low, int high)
108
+{
108 109
     int ret;
109 110
     ASSERT(low <= high);
110 111
     ret = low + (get_random() % (high - low + 1));
... ...
@@ -181,7 +183,8 @@ ask_gremlin(int flags)
181 181
  * Possibly corrupt a packet.
182 182
  */
183 183
 void
184
-corrupt_gremlin(struct buffer *buf, int flags) {
184
+corrupt_gremlin(struct buffer *buf, int flags)
185
+{
185 186
     const int corrupt_level = GREMLIN_CORRUPT_LEVEL(flags);
186 187
     if (corrupt_level)
187 188
     {
... ...
@@ -194,7 +197,8 @@ corrupt_gremlin(struct buffer *buf, int flags) {
194 194
                     uint8_t r = roll(0, 255);
195 195
                     int method = roll(0, 5);
196 196
 
197
-                    switch (method) {
197
+                    switch (method)
198
+                    {
198 199
                         case 0: /* corrupt the first byte */
199 200
                             *BPTR(buf) = r;
200 201
                             break;
... ...
@@ -232,6 +236,7 @@ corrupt_gremlin(struct buffer *buf, int flags) {
232 232
 
233 233
 #else  /* ifdef ENABLE_DEBUG */
234 234
 static void
235
-dummy(void) {
235
+dummy(void)
236
+{
236 237
 }
237 238
 #endif /* ifdef ENABLE_DEBUG */
... ...
@@ -44,7 +44,8 @@ CvtHex(
44 44
     unsigned short i;
45 45
     unsigned char j;
46 46
 
47
-    for (i = 0; i < HASHLEN; i++) {
47
+    for (i = 0; i < HASHLEN; i++)
48
+    {
48 49
         j = (Bin[i] >> 4) & 0xf;
49 50
         if (j <= 9)
50 51
         {
... ...
@@ -342,7 +342,8 @@ next_connection_entry(struct context *c)
342 342
     struct connection_entry *ce;
343 343
     int n_cycles = 0;
344 344
 
345
-    do {
345
+    do
346
+    {
346 347
         ce_defined = true;
347 348
         if (c->options.no_advance && l->current >= 0)
348 349
         {
... ...
@@ -540,8 +541,10 @@ context_init_1(struct context *c)
540 540
         int i;
541 541
         pkcs11_initialize(true, c->options.pkcs11_pin_cache_period);
542 542
         for (i = 0; i<MAX_PARMS && c->options.pkcs11_providers[i] != NULL; i++)
543
+        {
543 544
             pkcs11_addProvider(c->options.pkcs11_providers[i], c->options.pkcs11_protected_authentication[i],
544 545
                                c->options.pkcs11_private_mode[i], c->options.pkcs11_cert_private[i]);
546
+        }
545 547
     }
546 548
 #endif
547 549
 
... ...
@@ -621,7 +624,9 @@ init_static(void)
621 621
     {
622 622
         int i;
623 623
         for (i = 0; i < argc; ++i)
624
+        {
624 625
             msg(M_INFO, "argv[%d] = '%s'", i, argv[i]);
626
+        }
625 627
     }
626 628
 #endif
627 629
 
... ...
@@ -767,7 +772,9 @@ init_static(void)
767 767
                 {
768 768
                     int i;
769 769
                     for (i = 0; i < SIZE(text); ++i)
770
+                    {
770 771
                         buffer_list_push(bl, (unsigned char *)text[i]);
772
+                    }
771 773
                 }
772 774
                 printf("[cap=%d i=%d] *************************\n", listcap, iter);
773 775
                 if (!(iter & 8))
... ...
@@ -790,7 +797,9 @@ init_static(void)
790 790
                         int c;
791 791
                         printf("'");
792 792
                         while ((c = buf_read_u8(buf)) >= 0)
793
+                        {
793 794
                             putchar(c);
795
+                        }
794 796
                         printf("'\n");
795 797
                         buffer_list_advance(bl, 0);
796 798
                     }
... ...
@@ -106,7 +106,8 @@ interval_schedule_wakeup(struct interval *top, interval_t *wakeup)
106 106
  * In wakeup seconds, interval_test will return true once.
107 107
  */
108 108
 static inline void
109
-interval_future_trigger(struct interval *top, interval_t wakeup) {
109
+interval_future_trigger(struct interval *top, interval_t wakeup)
110
+{
110 111
     if (wakeup)
111 112
     {
112 113
 #if INTERVAL_DEBUG
... ...
@@ -476,7 +476,8 @@ list_test(void)
476 476
             int inc = 0;
477 477
             int count = 0;
478 478
 
479
-            for (base = 0; base < hash_n_buckets(hash); base += inc) {
479
+            for (base = 0; base < hash_n_buckets(hash); base += inc)
480
+            {
480 481
                 struct hash_iterator hi;
481 482
                 struct hash_element *he;
482 483
                 inc = (get_random() % 3) + 1;
... ...
@@ -670,6 +671,7 @@ hash_func(const uint8_t *k, uint32_t length, uint32_t initval)
670 670
 
671 671
 #else  /* if P2MP_SERVER */
672 672
 static void
673
-dummy(void) {
673
+dummy(void)
674
+{
674 675
 }
675 676
 #endif /* P2MP_SERVER */
... ...
@@ -267,6 +267,7 @@ const struct compress_alg lzo_alg = {
267 267
 
268 268
 #else  /* if defined(ENABLE_LZO) */
269 269
 static void
270
-dummy(void) {
270
+dummy(void)
271
+{
271 272
 }
272 273
 #endif /* ENABLE_LZO */
... ...
@@ -1984,7 +1984,9 @@ man_process_command(struct management *man, const char *line)
1984 1984
         {
1985 1985
             int i;
1986 1986
             for (i = 0; i < nparms; ++i)
1987
+            {
1987 1988
                 msg(M_INFO, "[%d] '%s'", i, parms[i]);
1989
+            }
1988 1990
         }
1989 1991
 #endif
1990 1992
 
... ...
@@ -3088,7 +3090,8 @@ management_io(struct management *man)
3088 3088
                 if (net_events & FD_READ)
3089 3089
                 {
3090 3090
                     while (man_read(man) > 0)
3091
-                        ;
3091
+                    {
3092
+                    }
3092 3093
                     net_event_win32_clear_selected_events(&man->connection.ne32, FD_READ);
3093 3094
                 }
3094 3095
 
... ...
@@ -3311,7 +3314,8 @@ man_wait_for_client_connection(struct management *man,
3311 3311
         {
3312 3312
             msg(D_MANAGEMENT, "Need information from management interface, waiting...");
3313 3313
         }
3314
-        do {
3314
+        do
3315
+        {
3315 3316
             man_standalone_event_loop(man, signal_received, expire);
3316 3317
             if (signal_received && *signal_received)
3317 3318
             {
... ...
@@ -3929,7 +3933,9 @@ log_history_free_contents(struct log_history *h)
3929 3929
 {
3930 3930
     int i;
3931 3931
     for (i = 0; i < h->size; ++i)
3932
+    {
3932 3933
         log_entry_free_contents(&h->array[log_index(h, i)]);
3934
+    }
3933 3935
     free(h->array);
3934 3936
 }
3935 3937
 
... ...
@@ -3973,7 +3979,9 @@ log_history_resize(struct log_history *h, const int capacity)
3973 3973
         log_history_obj_init(&newlog, capacity);
3974 3974
 
3975 3975
         for (i = 0; i < h->size; ++i)
3976
+        {
3976 3977
             log_history_add(&newlog, &h->array[log_index(h, i)]);
3978
+        }
3977 3979
 
3978 3980
         log_history_free_contents(h);
3979 3981
         *h = newlog;
... ...
@@ -3995,6 +4003,7 @@ log_history_ref(const struct log_history *h, const int index)
3995 3995
 
3996 3996
 #else  /* ifdef ENABLE_MANAGEMENT */
3997 3997
 static void
3998
-dummy(void) {
3998
+dummy(void)
3999
+{
3999 4000
 }
4000 4001
 #endif /* ENABLE_MANAGEMENT */
... ...
@@ -174,6 +174,7 @@ mbuf_dereference_instance(struct mbuf_set *ms, struct multi_instance *mi)
174 174
 
175 175
 #else  /* if P2MP */
176 176
 static void
177
-dummy(void) {
177
+dummy(void)
178
+{
178 179
 }
179 180
 #endif /* P2MP */
... ...
@@ -650,7 +650,8 @@ const char *
650 650
 env_set_get(const struct env_set *es, const char *name)
651 651
 {
652 652
     const struct env_item *item = es->list;
653
-    while (item && !env_string_equal(item->string, name)) {
653
+    while (item && !env_string_equal(item->string, name))
654
+    {
654 655
         item = item->next;
655 656
     }
656 657
     return item ? item->string : NULL;
... ...
@@ -1547,7 +1548,9 @@ make_env_array(const struct env_set *es,
1547 1547
     if (es)
1548 1548
     {
1549 1549
         for (e = es->list; e != NULL; e = e->next)
1550
+        {
1550 1551
             ++n;
1552
+        }
1551 1553
     }
1552 1554
 
1553 1555
     /* alloc return array */
... ...
@@ -1609,7 +1612,9 @@ make_inline_array(const char *str, struct gc_arena *gc)
1609 1609
 
1610 1610
     buf_set_read(&buf, (const uint8_t *) str, strlen(str));
1611 1611
     while (buf_parse(&buf, '\n', line, sizeof(line)))
1612
+    {
1612 1613
         ++len;
1614
+    }
1613 1615
 
1614 1616
     /* alloc return array */
1615 1617
     ALLOC_ARRAY_CLEAR_GC(ret, char *, len + 1, gc);
... ...
@@ -1639,7 +1644,9 @@ make_arg_copy(char **p, struct gc_arena *gc)
1639 1639
     ALLOC_ARRAY_CLEAR_GC(ret, char *, max_parms, gc);
1640 1640
 
1641 1641
     for (i = 0; i < len; ++i)
1642
+    {
1642 1643
         ret[i] = p[i];
1644
+    }
1643 1645
 
1644 1646
     return (const char **)ret;
1645 1647
 }
... ...
@@ -562,6 +562,7 @@ mroute_helper_free(struct mroute_helper *mh)
562 562
 
563 563
 #else  /* if P2MP_SERVER */
564 564
 static void
565
-dummy(void) {
565
+dummy(void)
566
+{
566 567
 }
567 568
 #endif /* P2MP_SERVER */
... ...
@@ -161,7 +161,8 @@ mss_fixup_dowork(struct buffer *buf, uint16_t maxmss)
161 161
     for (olen = hlen - sizeof(struct openvpn_tcphdr),
162 162
          opt = (uint8_t *)(tc + 1);
163 163
          olen > 0;
164
-         olen -= optlen, opt += optlen) {
164
+         olen -= optlen, opt += optlen)
165
+    {
165 166
         if (*opt == OPENVPN_TCPOPT_EOL)
166 167
         {
167 168
             break;
... ...
@@ -587,7 +587,8 @@ multi_tcp_action(struct multi_context *m, struct multi_instance *mi, int action,
587 587
 {
588 588
     bool tun_input_pending = false;
589 589
 
590
-    do {
590
+    do
591
+    {
591 592
         dmsg(D_MULTI_DEBUG, "MULTI TCP: multi_tcp_action a=%s p=%d",
592 593
              pract(action),
593 594
              poll);
... ...
@@ -537,10 +537,14 @@ multi_del_iroutes(struct multi_context *m,
537 537
     if (TUNNEL_TYPE(mi->context.c1.tuntap) == DEV_TYPE_TUN)
538 538
     {
539 539
         for (ir = mi->context.options.iroutes; ir != NULL; ir = ir->next)
540
+        {
540 541
             mroute_helper_del_iroute46(m->route_helper, ir->netbits);
542
+        }
541 543
 
542 544
         for (ir6 = mi->context.options.iroutes_ipv6; ir6 != NULL; ir6 = ir6->next)
545
+        {
543 546
             mroute_helper_del_iroute46(m->route_helper, ir6->netbits);
547
+        }
544 548
     }
545 549
 }
546 550
 
... ...
@@ -819,7 +823,8 @@ multi_create_instance(struct multi_context *m, const struct mroute_addr *real)
819 819
     mi->did_iter = true;
820 820
 
821 821
 #ifdef MANAGEMENT_DEF_AUTH
822
-    do {
822
+    do
823
+    {
823 824
         mi->context.c2.mda_context.cid = m->cid_counter++;
824 825
     } while (!hash_add(m->cid_hash, &mi->context.c2.mda_context.cid, mi, false));
825 826
     mi->did_cid_hash = true;
... ...
@@ -2949,10 +2954,14 @@ gremlin_flood_clients(struct multi_context *m)
2949 2949
             parm.packet_size);
2950 2950
 
2951 2951
         for (i = 0; i < parm.packet_size; ++i)
2952
+        {
2952 2953
             ASSERT(buf_write_u8(&buf, get_random() & 0xFF));
2954
+        }
2953 2955
 
2954 2956
         for (i = 0; i < parm.n_packets; ++i)
2957
+        {
2955 2958
             multi_bcast(m, &buf, NULL, NULL);
2959
+        }
2956 2960
 
2957 2961
         gc_free(&gc);
2958 2962
     }
... ...
@@ -3375,6 +3384,7 @@ tunnel_server(struct context *top)
3375 3375
 
3376 3376
 #else  /* if P2MP_SERVER */
3377 3377
 static void
3378
-dummy(void) {
3378
+dummy(void)
3379
+{
3379 3380
 }
3380 3381
 #endif /* P2MP_SERVER */
... ...
@@ -124,7 +124,8 @@ gen_nonce(unsigned char *nonce)
124 124
     /* Generates 8 random bytes to be used as client nonce */
125 125
     int i;
126 126
 
127
-    for (i = 0; i<8; i++) {
127
+    for (i = 0; i<8; i++)
128
+    {
128 129
         nonce[i] = (unsigned char)get_random();
129 130
     }
130 131
 }
... ...
@@ -135,7 +136,10 @@ my_strupr(unsigned char *str)
135 135
     /* converts string to uppercase in place */
136 136
     unsigned char *tmp = str;
137 137
 
138
-    do *str = toupper(*str); while (*(++str));
138
+    do
139
+    {
140
+        *str = toupper(*str);
141
+    } while (*(++str));
139 142
     return tmp;
140 143
 }
141 144
 
... ...
@@ -373,6 +377,7 @@ ntlm_phase_3(const struct http_proxy_info *p, const char *phase_2, struct gc_are
373 373
 
374 374
 #else  /* if NTLM */
375 375
 static void
376
-dummy(void) {
376
+dummy(void)
377
+{
377 378
 }
378 379
 #endif /* if NTLM */
... ...
@@ -430,6 +430,7 @@ process_received_occ_msg(struct context *c)
430 430
 
431 431
 #else  /* ifdef ENABLE_OCC */
432 432
 static void
433
-dummy(void) {
433
+dummy(void)
434
+{
434 435
 }
435 436
 #endif /* ifdef ENABLE_OCC */
... ...
@@ -332,7 +332,8 @@ openvpn_main(int argc, char *argv[])
332 332
 
333 333
 #ifdef _WIN32
334 334
 int
335
-wmain(int argc, wchar_t *wargv[]) {
335
+wmain(int argc, wchar_t *wargv[])
336
+{
336 337
     char **argv;
337 338
     int ret;
338 339
     int i;
... ...
@@ -361,7 +362,8 @@ wmain(int argc, wchar_t *wargv[]) {
361 361
 }
362 362
 #else  /* ifdef _WIN32 */
363 363
 int
364
-main(int argc, char *argv[]) {
364
+main(int argc, char *argv[])
365
+{
365 366
     return openvpn_main(argc, argv);
366 367
 }
367 368
 #endif /* ifdef _WIN32 */
... ...
@@ -996,7 +996,9 @@ setenv_settings(struct env_set *es, const struct options *o)
996 996
     {
997 997
         int i;
998 998
         for (i = 0; i < o->connection_list->len; ++i)
999
+        {
999 1000
             setenv_connection_entry(es, o->connection_list->array[i], i+1);
1001
+        }
1000 1002
     }
1001 1003
     else
1002 1004
     {
... ...
@@ -1756,7 +1758,9 @@ show_settings(const struct options *o)
1756 1756
     {
1757 1757
         int i;
1758 1758
         for (i = 0; i<MAX_PARMS; i++)
1759
+        {
1759 1760
             SHOW_INT(remote_cert_ku[i]);
1761
+        }
1760 1762
     }
1761 1763
     SHOW_STR(remote_cert_eku);
1762 1764
     SHOW_INT(ssl_flags);
... ...
@@ -1784,22 +1788,30 @@ show_settings(const struct options *o)
1784 1784
     {
1785 1785
         int i;
1786 1786
         for (i = 0; i<MAX_PARMS && o->pkcs11_providers[i] != NULL; i++)
1787
+        {
1787 1788
             SHOW_PARM(pkcs11_providers, o->pkcs11_providers[i], "%s");
1789
+        }
1788 1790
     }
1789 1791
     {
1790 1792
         int i;
1791 1793
         for (i = 0; i<MAX_PARMS; i++)
1794
+        {
1792 1795
             SHOW_PARM(pkcs11_protected_authentication, o->pkcs11_protected_authentication[i] ? "ENABLED" : "DISABLED", "%s");
1796
+        }
1793 1797
     }
1794 1798
     {
1795 1799
         int i;
1796 1800
         for (i = 0; i<MAX_PARMS; i++)
1801
+        {
1797 1802
             SHOW_PARM(pkcs11_private_mode, o->pkcs11_private_mode[i], "%08x");
1803
+        }
1798 1804
     }
1799 1805
     {
1800 1806
         int i;
1801 1807
         for (i = 0; i<MAX_PARMS; i++)
1808
+        {
1802 1809
             SHOW_PARM(pkcs11_cert_private, o->pkcs11_cert_private[i] ? "ENABLED" : "DISABLED", "%s");
1810
+        }
1803 1811
     }
1804 1812
     SHOW_INT(pkcs11_pin_cache_period);
1805 1813
     SHOW_STR(pkcs11_id);
... ...
@@ -2926,7 +2938,9 @@ options_postprocess_verify(const struct options *o)
2926 2926
     {
2927 2927
         int i;
2928 2928
         for (i = 0; i < o->connection_list->len; ++i)
2929
+        {
2929 2930
             options_postprocess_verify_ce(o, o->connection_list->array[i]);
2931
+        }
2930 2932
     }
2931 2933
     else
2932 2934
     {
... ...
@@ -2977,7 +2991,9 @@ options_postprocess_mutate(struct options *o)
2977 2977
 
2978 2978
     ASSERT(o->connection_list);
2979 2979
     for (i = 0; i < o->connection_list->len; ++i)
2980
+    {
2980 2981
         options_postprocess_mutate_ce(o, o->connection_list->array[i]);
2982
+    }
2981 2983
 
2982 2984
 #ifdef ENABLE_CRYPTO
2983 2985
     if (o->tls_server)
... ...
@@ -3785,7 +3801,9 @@ options_warning_safe_scan1(const int msglevel,
3785 3785
     char *p = gc_malloc(OPTION_PARM_SIZE, true, &gc);
3786 3786
 
3787 3787
     while (buf_parse(&b, delim, p, OPTION_PARM_SIZE))
3788
+    {
3788 3789
         options_warning_safe_scan2(msglevel, delim, report_inconsistent, p, b2_src, b1_name, b2_name);
3790
+    }
3789 3791
 
3790 3792
     gc_free(&gc);
3791 3793
 }
... ...
@@ -4413,7 +4431,10 @@ read_inline_file(struct in_src *is, const char *close_tag, struct gc_arena *gc)
4413 4413
     {
4414 4414
         char *line_ptr = line;
4415 4415
         /* Remove leading spaces */
4416
-        while (isspace(*line_ptr)) line_ptr++;
4416
+        while (isspace(*line_ptr))
4417
+        {
4418
+            line_ptr++;
4419
+        }
4417 4420
         if (!strncmp(line_ptr, close_tag, strlen(close_tag)))
4418 4421
         {
4419 4422
             endtagfound = true;
... ...
@@ -5303,18 +5324,24 @@ add_option(struct options *options,
5303 5303
         VERIFY_PERMISSION(OPT_P_GENERAL);
5304 5304
         /* Find out how many options to be ignored */
5305 5305
         for (i = 1; p[i]; i++)
5306
+        {
5306 5307
             numignored++;
5308
+        }
5307 5309
 
5308 5310
         /* add number of options already ignored */
5309 5311
         for (i = 0; options->ignore_unknown_option
5310 5312
              && options->ignore_unknown_option[i]; i++)
5313
+        {
5311 5314
             numignored++;
5315
+        }
5312 5316
 
5313 5317
         /* Allocate array */
5314 5318
         ALLOC_ARRAY_GC(ignore, const char *, numignored+1, &options->gc);
5315 5319
         for (i = 0; options->ignore_unknown_option
5316 5320
              && options->ignore_unknown_option[i]; i++)
5321
+        {
5317 5322
             ignore[i] = options->ignore_unknown_option[i];
5323
+        }
5318 5324
 
5319 5325
         options->ignore_unknown_option = ignore;
5320 5326
 
... ...
@@ -5998,7 +6025,8 @@ add_option(struct options *options,
5998 5998
             struct http_custom_header *custom_header = NULL;
5999 5999
             int i;
6000 6000
             /* Find the first free header */
6001
-            for (i = 0; i < MAX_CUSTOM_HTTP_HEADER; i++) {
6001
+            for (i = 0; i < MAX_CUSTOM_HTTP_HEADER; i++)
6002
+            {
6002 6003
                 if (!ho->custom_headers[i].name)
6003 6004
                 {
6004 6005
                     custom_header = &ho->custom_headers[i];
... ...
@@ -7891,7 +7919,9 @@ add_option(struct options *options,
7891 7891
         VERIFY_PERMISSION(OPT_P_GENERAL);
7892 7892
 
7893 7893
         for (j = 1; j < MAX_PARMS && p[j] != NULL; ++j)
7894
+        {
7894 7895
             sscanf(p[j], "%x", &(options->remote_cert_ku[j-1]));
7896
+        }
7895 7897
     }
7896 7898
     else if (streq(p[0], "remote-cert-eku") && p[1] && !p[2])
7897 7899
     {
... ...
@@ -8020,10 +8050,16 @@ add_option(struct options *options,
8020 8020
         if (strncmp("ext:", s, 4) != 0)
8021 8021
         {
8022 8022
             size_t i = 0;
8023
-            while (s[i] && !isupper(s[i])) i++;
8023
+            while (s[i] && !isupper(s[i]))
8024
+            {
8025
+                i++;
8026
+            }
8024 8027
             if (strlen(s) == i)
8025 8028
             {
8026
-                while ((*s = toupper(*s)) != '\0') s++;
8029
+                while ((*s = toupper(*s)) != '\0')
8030
+                {
8031
+                    s++;
8032
+                }
8027 8033
                 msg(M_WARN, "DEPRECATED FEATURE: automatically upcased the "
8028 8034
                     "--x509-username-field parameter to '%s'; please update your"
8029 8035
                     "configuration", p[1]);
... ...
@@ -8077,7 +8113,9 @@ add_option(struct options *options,
8077 8077
         VERIFY_PERMISSION(OPT_P_GENERAL);
8078 8078
 
8079 8079
         for (j = 1; j < MAX_PARMS && p[j] != NULL; ++j)
8080
+        {
8080 8081
             options->pkcs11_providers[j-1] = p[j];
8082
+        }
8081 8083
     }
8082 8084
     else if (streq(p[0], "pkcs11-protected-authentication"))
8083 8085
     {
... ...
@@ -8086,7 +8124,9 @@ add_option(struct options *options,
8086 8086
         VERIFY_PERMISSION(OPT_P_GENERAL);
8087 8087
 
8088 8088
         for (j = 1; j < MAX_PARMS && p[j] != NULL; ++j)
8089
+        {
8089 8090
             options->pkcs11_protected_authentication[j-1] = atoi(p[j]) != 0 ? 1 : 0;
8091
+        }
8090 8092
     }
8091 8093
     else if (streq(p[0], "pkcs11-private-mode") && p[1])
8092 8094
     {
... ...
@@ -8095,7 +8135,9 @@ add_option(struct options *options,
8095 8095
         VERIFY_PERMISSION(OPT_P_GENERAL);
8096 8096
 
8097 8097
         for (j = 1; j < MAX_PARMS && p[j] != NULL; ++j)
8098
+        {
8098 8099
             sscanf(p[j], "%x", &(options->pkcs11_private_mode[j-1]));
8100
+        }
8099 8101
     }
8100 8102
     else if (streq(p[0], "pkcs11-cert-private"))
8101 8103
     {
... ...
@@ -8104,7 +8146,9 @@ add_option(struct options *options,
8104 8104
         VERIFY_PERMISSION(OPT_P_GENERAL);
8105 8105
 
8106 8106
         for (j = 1; j < MAX_PARMS && p[j] != NULL; ++j)
8107
+        {
8107 8108
             options->pkcs11_cert_private[j-1] = atoi(p[j]) != 0 ? 1 : 0;
8109
+        }
8108 8110
     }
8109 8111
     else if (streq(p[0], "pkcs11-pin-cache") && p[1] && !p[2])
8110 8112
     {
... ...
@@ -289,7 +289,8 @@ tv_within_sigma(const struct timeval *t1, const struct timeval *t2, unsigned int
289 289
  * called again.
290 290
  */
291 291
 static inline void
292
-interval_earliest_wakeup(interval_t *wakeup, time_t at, time_t current) {
292
+interval_earliest_wakeup(interval_t *wakeup, time_t at, time_t current)
293
+{
293 294
     if (at > current)
294 295
     {
295 296
         const interval_t delta = (interval_t) (at - current);
... ...
@@ -629,7 +629,8 @@ packet_id_interactive_test()
629 629
 
630 630
     packet_id_init(&pid, seq_backtrack, time_backtrack);
631 631
 
632
-    while (true) {
632
+    while (true)
633
+    {
633 634
         char buf[80];
634 635
         if (!fgets(buf, sizeof(buf), stdin))
635 636
         {
... ...
@@ -147,12 +147,14 @@ push_perf_index(int pindex)
147 147
     {
148 148
         int i;
149 149
         for (i = 0; i < sindex; ++i)
150
+        {
150 151
             if (perf_set.stack[i] == pindex)
151 152
             {
152 153
                 perf_print_state(M_INFO);
153 154
                 msg(M_FATAL, "PERF: push_perf_index %s failed",
154 155
                     metric_names [pindex]);
155 156
             }
157
+        }
156 158
 
157 159
         perf_set.stack[sindex] = pindex;
158 160
         perf_set.stack_len = newlen;
... ...
@@ -321,7 +323,8 @@ perf_print_state(int lev)
321 321
 #else  /* ifdef ENABLE_PERFORMANCE_METRICS */
322 322
 #ifdef _MSC_VER  /* Dummy function needed to avoid empty file compiler warning in Microsoft VC */
323 323
 static void
324
-dummy(void) {
324
+dummy(void)
325
+{
325 326
 }
326 327
 #endif
327 328
 #endif /* ifdef ENABLE_PERFORMANCE_METRICS */
... ...
@@ -76,13 +76,16 @@ void perf_output_results(void);
76 76
 #else  /* ifdef ENABLE_PERFORMANCE_METRICS */
77 77
 
78 78
 static inline void
79
-perf_push(int type) {
79
+perf_push(int type)
80
+{
80 81
 }
81 82
 static inline void
82
-perf_pop(void) {
83
+perf_pop(void)
84
+{
83 85
 }
84 86
 static inline void
85
-perf_output_results(void) {
87
+perf_output_results(void)
88
+{
86 89
 }
87 90
 
88 91
 #endif /* ifdef ENABLE_PERFORMANCE_METRICS */
... ...
@@ -45,21 +45,24 @@
45 45
 
46 46
 static
47 47
 time_t
48
-__mytime(void) {
48
+__mytime(void)
49
+{
49 50
     return openvpn_time(NULL);
50 51
 }
51 52
 
52 53
 #if !defined(_WIN32)
53 54
 static
54 55
 int
55
-__mygettimeofday(struct timeval *tv) {
56
+__mygettimeofday(struct timeval *tv)
57
+{
56 58
     return gettimeofday(tv, NULL);
57 59
 }
58 60
 #endif
59 61
 
60 62
 static
61 63
 void
62
-__mysleep(const unsigned long usec) {
64
+__mysleep(const unsigned long usec)
65
+{
63 66
 #if defined(_WIN32)
64 67
     Sleep(usec/1000);
65 68
 #else
... ...
@@ -84,10 +87,12 @@ static
84 84
 unsigned
85 85
 _pkcs11_msg_pkcs112openvpn(
86 86
     const unsigned flags
87
-    ) {
87
+    )
88
+{
88 89
     unsigned openvpn_flags;
89 90
 
90
-    switch (flags) {
91
+    switch (flags)
92
+    {
91 93
         case PKCS11H_LOG_DEBUG2:
92 94
             openvpn_flags = D_PKCS11_DEBUG;
93 95
             break;
... ...
@@ -124,7 +129,8 @@ static
124 124
 unsigned
125 125
 _pkcs11_msg_openvpn2pkcs11(
126 126
     const unsigned flags
127
-    ) {
127
+    )
128
+{
128 129
     unsigned pkcs11_flags;
129 130
 
130 131
     if ((flags & D_PKCS11_DEBUG) != 0)
... ...
@@ -166,7 +172,8 @@ _pkcs11_openvpn_log(
166 166
     unsigned flags,
167 167
     const char *const szFormat,
168 168
     va_list args
169
-    ) {
169
+    )
170
+{
170 171
     char Buffer[10*1024];
171 172
 
172 173
     (void)global_data;
... ...
@@ -184,7 +191,8 @@ _pkcs11_openvpn_token_prompt(
184 184
     void *const user_data,
185 185
     const pkcs11h_token_id_t token,
186 186
     const unsigned retry
187
-    ) {
187
+    )
188
+{
188 189
     struct user_pass token_resp;
189 190
 
190 191
     (void)global_data;
... ...
@@ -229,7 +237,8 @@ _pkcs11_openvpn_pin_prompt(
229 229
     const unsigned retry,
230 230
     char *const pin,
231 231
     const size_t pin_max
232
-    ) {
232
+    )
233
+{
233 234
     struct user_pass token_pass;
234 235
     char prompt[1024];
235 236
 
... ...
@@ -275,7 +284,8 @@ bool
275 275
 pkcs11_initialize(
276 276
     const bool protected_auth,
277 277
     const int nPINCachePeriod
278
-    ) {
278
+    )
279
+{
279 280
     CK_RV rv = CKR_FUNCTION_FAILED;
280 281
 
281 282
     dmsg(
... ...
@@ -347,7 +357,8 @@ cleanup:
347 347
 }
348 348
 
349 349
 void
350
-pkcs11_terminate() {
350
+pkcs11_terminate()
351
+{
351 352
     dmsg(
352 353
         D_PKCS11_DEBUG,
353 354
         "PKCS#11: pkcs11_terminate - entered"
... ...
@@ -367,7 +378,8 @@ pkcs11_addProvider(
367 367
     const bool protected_auth,
368 368
     const unsigned private_mode,
369 369
     const bool cert_private
370
-    ) {
370
+    )
371
+{
371 372
     CK_RV rv = CKR_OK;
372 373
 
373 374
     ASSERT(provider!=NULL);
... ...
@@ -411,12 +423,14 @@ pkcs11_addProvider(
411 411
 }
412 412
 
413 413
 int
414
-pkcs11_logout() {
414
+pkcs11_logout()
415
+{
415 416
     return pkcs11h_logout() == CKR_OK;
416 417
 }
417 418
 
418 419
 int
419
-pkcs11_management_id_count() {
420
+pkcs11_management_id_count()
421
+{
420 422
     pkcs11h_certificate_id_list_t id_list = NULL;
421 423
     pkcs11h_certificate_id_list_t t = NULL;
422 424
     CK_RV rv = CKR_OK;
... ...
@@ -441,7 +455,8 @@ pkcs11_management_id_count() {
441 441
         goto cleanup;
442 442
     }
443 443
 
444
-    for (count = 0, t = id_list; t != NULL; t = t->next) {
444
+    for (count = 0, t = id_list; t != NULL; t = t->next)
445
+    {
445 446
         count++;
446 447
     }
447 448
 
... ...
@@ -467,7 +482,8 @@ pkcs11_management_id_get(
467 467
     const int index,
468 468
     char **id,
469 469
     char **base64
470
-    ) {
470
+    )
471
+{
471 472
     pkcs11h_certificate_id_list_t id_list = NULL;
472 473
     pkcs11h_certificate_id_list_t entry = NULL;
473 474
 #if 0 /* certificate_id seems to be unused -- JY */
... ...
@@ -511,7 +527,8 @@ pkcs11_management_id_get(
511 511
 
512 512
     entry = id_list;
513 513
     count = 0;
514
-    while (entry != NULL && count != index) {
514
+    while (entry != NULL && count != index)
515
+    {
515 516
         count++;
516 517
         entry = entry->next;
517 518
     }
... ...
@@ -653,7 +670,8 @@ tls_ctx_use_pkcs11(
653 653
     struct tls_root_ctx *const ssl_ctx,
654 654
     bool pkcs11_id_management,
655 655
     const char *const pkcs11_id
656
-    ) {
656
+    )
657
+{
657 658
     pkcs11h_certificate_id_t certificate_id = NULL;
658 659
     pkcs11h_certificate_t certificate = NULL;
659 660
     CK_RV rv = CKR_OK;
... ...
@@ -784,7 +802,8 @@ _pkcs11_openvpn_show_pkcs11_ids_pin_prompt(
784 784
     const unsigned retry,
785 785
     char *const pin,
786 786
     const size_t pin_max
787
-    ) {
787
+    )
788
+{
788 789
     struct gc_arena gc = gc_new();
789 790
     struct buffer pass_prompt = alloc_buf_gc(128, &gc);
790 791
 
... ...
@@ -817,7 +836,8 @@ void
817 817
 show_pkcs11_ids(
818 818
     const char *const provider,
819 819
     bool cert_private
820
-    ) {
820
+    )
821
+{
821 822
     struct gc_arena gc = gc_new();
822 823
     pkcs11h_certificate_id_list_t user_certificates = NULL;
823 824
     pkcs11h_certificate_id_list_t current = NULL;
... ...
@@ -888,7 +908,8 @@ show_pkcs11_ids(
888 888
             "--pkcs11-id option please remember to use single quote mark.\n"
889 889
         )
890 890
         );
891
-    for (current = user_certificates; current != NULL; current = current->next) {
891
+    for (current = user_certificates; current != NULL; current = current->next)
892
+    {
892 893
         pkcs11h_certificate_t certificate = NULL;
893 894
         char *dn = NULL;
894 895
         char serial[1024] = {0};
... ...
@@ -1006,7 +1027,8 @@ cleanup:
1006 1006
 #else  /* if defined(ENABLE_PKCS11) */
1007 1007
 #ifdef _MSC_VER  /* Dummy function needed to avoid empty file compiler warning in Microsoft VC */
1008 1008
 static void
1009
-dummy(void) {
1009
+dummy(void)
1010
+{
1010 1011
 }
1011 1012
 #endif
1012 1013
 #endif /* ENABLE_PKCS11 */
... ...
@@ -745,7 +745,9 @@ plugin_common_close(struct plugin_common *pc)
745 745
         int i;
746 746
 
747 747
         for (i = 0; i < pc->n; ++i)
748
+        {
748 749
             plugin_close_item(&pc->plugins[i]);
750
+        }
749 751
         free(pc);
750 752
     }
751 753
 }
... ...
@@ -883,7 +885,9 @@ plugin_abort(void)
883 883
         int i;
884 884
 
885 885
         for (i = 0; i < pc->n; ++i)
886
+        {
886 887
             plugin_abort_item(&pc->plugins[i]);
888
+        }
887 889
     }
888 890
 }
889 891
 
... ...
@@ -964,7 +968,9 @@ plugin_return_get_column(const struct plugin_return *src,
964 964
 
965 965
     dest->n = 0;
966 966
     for (i = 0; i < src->n; ++i)
967
+    {
967 968
         dest->list[i] = openvpn_plugin_string_list_find(src->list[i], colname);
969
+    }
968 970
     dest->n = i;
969 971
 }
970 972
 
... ...
@@ -973,7 +979,9 @@ plugin_return_free(struct plugin_return *pr)
973 973
 {
974 974
     int i;
975 975
     for (i = 0; i < pr->n; ++i)
976
+    {
976 977
         openvpn_plugin_string_list_free(pr->list[i]);
978
+    }
977 979
     pr->n = 0;
978 980
 }
979 981
 
... ...
@@ -1003,6 +1011,7 @@ plugin_return_print(const int msglevel, const char *prefix, const struct plugin_
1003 1003
 
1004 1004
 #else  /* ifdef ENABLE_PLUGIN */
1005 1005
 static void
1006
-dummy(void) {
1006
+dummy(void)
1007
+{
1007 1008
 }
1008 1009
 #endif /* ENABLE_PLUGIN */
... ...
@@ -215,7 +215,9 @@ ifconfig_pool_free(struct ifconfig_pool *pool)
215 215
     {
216 216
         int i;
217 217
         for (i = 0; i < pool->size; ++i)
218
+        {
218 219
             ifconfig_pool_entry_free(&pool->list[i], true);
220
+        }
219 221
         free(pool->list);
220 222
         free(pool);
221 223
     }
... ...
@@ -381,7 +381,9 @@ get_key_value(const char *str,       /* source string */
381 381
     bool escape = false;
382 382
 
383 383
     for (c = max_key_len-1; (*str && (*str != '=') && c--); )
384
+    {
384 385
         *key++ = *str++;
386
+    }
385 387
     *key = '\0';
386 388
 
387 389
     if ('=' != *str++)
... ...
@@ -475,7 +477,9 @@ get_pa_var(const char *key, const char *pa, struct gc_arena *gc)
475 475
             ++content;
476 476
         }
477 477
         while (*content && isspace(*content))
478
+        {
478 479
             ++content;
480
+        }
479 481
     }
480 482
 }
481 483
 
... ...
@@ -774,7 +778,8 @@ establish_http_proxy_passthru(struct http_proxy_info *p,
774 774
 
775 775
             /* receive and discard everything else */
776 776
             while (recv_line(sd, NULL, 0, 2, true, NULL, signal_received))
777
-                ;
777
+            {
778
+            }
778 779
 
779 780
             /* now send the phase 3 reply */
780 781
 
... ...
@@ -1041,7 +1046,8 @@ establish_http_proxy_passthru(struct http_proxy_info *p,
1041 1041
      * start of the OpenVPN data stream (put it in lookahead).
1042 1042
      */
1043 1043
     while (recv_line(sd, NULL, 0, 2, false, lookahead, signal_received))
1044
-        ;
1044
+    {
1045
+    }
1045 1046
 
1046 1047
     /* reset queried_creds so that we don't think that the next creds request is due to an auth error */
1047 1048
     p->queried_creds = false;
... ...
@@ -112,10 +112,12 @@ reliable_ack_packet_id_present(struct reliable_ack *ack, packet_id_type pid)
112 112
 {
113 113
     int i;
114 114
     for (i = 0; i < ack->len; ++i)
115
+    {
115 116
         if (ack->packet_id[i] == pid)
116 117
         {
117 118
             return true;
118 119
         }
120
+    }
119 121
     return false;
120 122
 }
121 123
 
... ...
@@ -242,7 +244,9 @@ reliable_ack_write(struct reliable_ack *ack,
242 242
         ASSERT(session_id_defined(sid));
243 243
         ASSERT(session_id_write(sid, &sub));
244 244
         for (i = 0, j = n; j < ack->len; )
245
+        {
245 246
             ack->packet_id[i++] = ack->packet_id[j++];
247
+        }
246 248
         ack->len = i;
247 249
     }
248 250
 
... ...
@@ -802,6 +806,7 @@ reliable_debug_print(const struct reliable *rel, char *desc)
802 802
 
803 803
 #else  /* ifdef ENABLE_CRYPTO */
804 804
 static void
805
-dummy(void) {
805
+dummy(void)
806
+{
806 807
 }
807 808
 #endif /* ENABLE_CRYPTO */
... ...
@@ -1281,7 +1281,9 @@ print_route_options(const struct route_option_list *rol,
1281 1281
             (rol->flags & RG_LOCAL) != 0);
1282 1282
     }
1283 1283
     for (ro = rol->routes; ro; ro = ro->next)
1284
+    {
1284 1285
         print_route_option(ro, level);
1286
+    }
1285 1287
 }
1286 1288
 
1287 1289
 void
... ...
@@ -1375,7 +1377,9 @@ print_routes(const struct route_list *rl, int level)
1375 1375
 {
1376 1376
     struct route_ipv4 *r;
1377 1377
     for (r = rl->routes; r; r = r->next)
1378
+    {
1378 1379
         print_route(r, level);
1380
+    }
1379 1381
 }
1380 1382
 
1381 1383
 static void
... ...
@@ -1404,7 +1408,9 @@ setenv_routes(struct env_set *es, const struct route_list *rl)
1404 1404
     int i = 1;
1405 1405
     struct route_ipv4 *r;
1406 1406
     for (r = rl->routes; r; r = r->next)
1407
+    {
1407 1408
         setenv_route(es, r, i++);
1409
+    }
1408 1410
 }
1409 1411
 
1410 1412
 static void
... ...
@@ -1433,7 +1439,9 @@ setenv_routes_ipv6(struct env_set *es, const struct route_ipv6_list *rl6)
1433 1433
     int i = 1;
1434 1434
     struct route_ipv6 *r6;
1435 1435
     for (r6 = rl6->routes_ipv6; r6; r6 = r6->next)
1436
+    {
1436 1437
         setenv_route_ipv6(es, r6, i++);
1438
+    }
1437 1439
 }
1438 1440
 
1439 1441
 /*
... ...
@@ -2623,7 +2631,9 @@ test_routes(const struct route_list *rl, const struct tuntap *tt)
2623 2623
         {
2624 2624
             struct route_ipv4 *r;
2625 2625
             for (r = rl->routes, len = 0; r; r = r->next, ++len)
2626
+            {
2626 2627
                 test_route_helper(&ret, &count, &good, &ambig, adapters, r->gateway);
2628
+            }
2627 2629
 
2628 2630
             if ((rl->flags & RG_ENABLE) && (rl->spec.flags & RTSA_REMOTE_ENDPOINT))
2629 2631
             {
... ...
@@ -3608,7 +3618,8 @@ get_default_gateway(struct route_gateway_info *rgi)
3608 3608
         msg(M_WARN, "GDG: problem writing to routing socket");
3609 3609
         goto done;
3610 3610
     }
3611
-    do {
3611
+    do
3612
+    {
3612 3613
         l = read(sockfd, (char *)&m_rtmsg, sizeof(m_rtmsg));
3613 3614
     } while (l > 0 && (rtm.rtm_seq != seq || rtm.rtm_pid != pid));
3614 3615
     close(sockfd);
... ...
@@ -354,7 +354,8 @@ bool del_route_ipapi(const struct route_ipv4 *r, const struct tuntap *tt);
354 354
 
355 355
 #else  /* ifdef _WIN32 */
356 356
 static inline bool
357
-test_routes(const struct route_list *rl, const struct tuntap *tt) {
357
+test_routes(const struct route_list *rl, const struct tuntap *tt)
358
+{
358 359
     return true;
359 360
 }
360 361
 #endif
... ...
@@ -377,7 +377,9 @@ schedule_add_modify(struct schedule *s, struct schedule_entry *e)
377 377
      * keeps the tree balanced.  Move the node up the tree until
378 378
      * its own priority is greater than that of its parent */
379 379
     while (e->parent && e->parent->pri > e->pri)
380
+    {
380 381
         schedule_rotate_up(s, e);
382
+    }
381 383
 }
382 384
 
383 385
 /*
... ...
@@ -623,7 +625,9 @@ schedule_print_work(struct schedule_entry *e, int indent)
623 623
     struct gc_arena gc = gc_new();
624 624
     int i;
625 625
     for (i = 0; i < indent; ++i)
626
+    {
626 627
         printf(" ");
628
+    }
627 629
     if (e)
628 630
     {
629 631
         printf("%s [%u] e=" ptr_format ", p=" ptr_format " lt=" ptr_format " gt=" ptr_format "\n",
... ...
@@ -64,6 +64,7 @@ session_id_print(const struct session_id *sid, struct gc_arena *gc)
64 64
 
65 65
 #else  /* ifdef ENABLE_CRYPTO */
66 66
 static void
67
-dummy(void) {
67
+dummy(void)
68
+{
68 69
 }
69 70
 #endif /* ENABLE_CRYPTO */
... ...
@@ -98,6 +98,7 @@ shaper_msg(struct shaper *s)
98 98
 
99 99
 #else  /* ifdef ENABLE_FEATURE_SHAPER */
100 100
 static void
101
-dummy(void) {
101
+dummy(void)
102
+{
102 103
 }
103 104
 #endif /* ENABLE_FEATURE_SHAPER */
... ...
@@ -205,7 +205,9 @@ do_preresolve_host(struct context *c,
205 205
         {
206 206
             struct cached_dns_entry *prev = c->c1.dns_cache;
207 207
             while (prev->next)
208
+            {
208 209
                 prev = prev->next;
210
+            }
209 211
             prev->next = ph;
210 212
         }
211 213
 
... ...
@@ -2008,7 +2010,8 @@ static void
2008 2008
 phase2_tcp_client(struct link_socket *sock, struct signal_info *sig_info)
2009 2009
 {
2010 2010
     bool proxy_retry = false;
2011
-    do {
2011
+    do
2012
+    {
2012 2013
         socket_connect(&sock->sd,
2013 2014
                        sock->info.lsa->current_remote->ai_addr,
2014 2015
                        get_server_poll_remaining_time(sock->server_poll_timeout),
... ...
@@ -2364,7 +2367,8 @@ link_socket_bad_incoming_addr(struct buffer *buf,
2364 2364
                 (int)from_addr->dest.addr.sa.sa_family,
2365 2365
                 print_sockaddr_ex(info->lsa->remote_list->ai_addr,":",PS_SHOW_PORT, &gc));
2366 2366
             /* print additional remote addresses */
2367
-            for (ai = info->lsa->remote_list->ai_next; ai; ai = ai->ai_next) {
2367
+            for (ai = info->lsa->remote_list->ai_next; ai; ai = ai->ai_next)
2368
+            {
2368 2369
                 msg(D_LINK_ERRORS,"or from peer address: %s",
2369 2370
                     print_sockaddr_ex(ai->ai_addr,":",PS_SHOW_PORT, &gc));
2370 2371
             }
... ...
@@ -3053,10 +3057,12 @@ ascii2proto(const char *proto_name)
3053 3053
 {
3054 3054
     int i;
3055 3055
     for (i = 0; i < SIZE(proto_names); ++i)
3056
+    {
3056 3057
         if (!strcmp(proto_name, proto_names[i].short_form))
3057 3058
         {
3058 3059
             return proto_names[i].proto;
3059 3060
         }
3061
+    }
3060 3062
     return -1;
3061 3063
 }
3062 3064
 
... ...
@@ -3065,10 +3071,12 @@ ascii2af(const char *proto_name)
3065 3065
 {
3066 3066
     int i;
3067 3067
     for (i = 0; i < SIZE(proto_names); ++i)
3068
+    {
3068 3069
         if (!strcmp(proto_name, proto_names[i].short_form))
3069 3070
         {
3070 3071
             return proto_names[i].proto_af;
3071 3072
         }
3073
+    }
3072 3074
     return 0;
3073 3075
 }
3074 3076
 
... ...
@@ -623,7 +623,8 @@ addr_defined(const struct openvpn_sockaddr *addr)
623 623
     {
624 624
         return 0;
625 625
     }
626
-    switch (addr->addr.sa.sa_family) {
626
+    switch (addr->addr.sa.sa_family)
627
+    {
627 628
         case AF_INET: return addr->addr.in4.sin_addr.s_addr != 0;
628 629
 
629 630
         case AF_INET6: return !IN6_IS_ADDR_UNSPECIFIED(&addr->addr.in6.sin6_addr);
... ...
@@ -639,7 +640,8 @@ addr_local(const struct sockaddr *addr)
639 639
     {
640 640
         return false;
641 641
     }
642
-    switch (addr->sa_family) {
642
+    switch (addr->sa_family)
643
+    {
643 644
         case AF_INET:
644 645
             return ((const struct sockaddr_in *)addr)->sin_addr.s_addr == htonl(INADDR_LOOPBACK);
645 646
 
... ...
@@ -660,7 +662,8 @@ addr_defined_ipi(const struct link_socket_actual *lsa)
660 660
     {
661 661
         return 0;
662 662
     }
663
-    switch (lsa->dest.addr.sa.sa_family) {
663
+    switch (lsa->dest.addr.sa.sa_family)
664
+    {
664 665
 #if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
665 666
         case AF_INET: return lsa->pi.in4.ipi_spec_dst.s_addr != 0;
666 667
 
... ...
@@ -687,7 +690,8 @@ link_socket_actual_defined(const struct link_socket_actual *act)
687 687
 static inline bool
688 688
 addr_match(const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2)
689 689
 {
690
-    switch (a1->addr.sa.sa_family) {
690
+    switch (a1->addr.sa.sa_family)
691
+    {
691 692
         case AF_INET:
692 693
             return a1->addr.in4.sin_addr.s_addr == a2->addr.in4.sin_addr.s_addr;
693 694
 
... ...
@@ -781,7 +785,8 @@ addrlist_port_match(const struct openvpn_sockaddr *a1, const struct addrinfo *a2
781 781
 static inline bool
782 782
 addr_port_match(const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2)
783 783
 {
784
-    switch (a1->addr.sa.sa_family) {
784
+    switch (a1->addr.sa.sa_family)
785
+    {
785 786
         case AF_INET:
786 787
             return a1->addr.in4.sin_addr.s_addr == a2->addr.in4.sin_addr.s_addr
787 788
                    && a1->addr.in4.sin_port == a2->addr.in4.sin_port;
... ...
@@ -818,7 +823,8 @@ addrlist_match_proto(const struct openvpn_sockaddr *a1,
818 818
 static inline void
819 819
 addr_zero_host(struct openvpn_sockaddr *addr)
820 820
 {
821
-    switch (addr->addr.sa.sa_family) {
821
+    switch (addr->addr.sa.sa_family)
822
+    {
822 823
         case AF_INET:
823 824
             addr->addr.in4.sin_addr.s_addr = 0;
824 825
             break;
... ...
@@ -846,7 +852,8 @@ int addr_guess_family(sa_family_t af,const char *name);
846 846
 static inline int
847 847
 af_addr_size(sa_family_t af)
848 848
 {
849
-    switch (af) {
849
+    switch (af)
850
+    {
850 851
         case AF_INET: return sizeof(struct sockaddr_in);
851 852
 
852 853
         case AF_INET6: return sizeof(struct sockaddr_in6);
... ...
@@ -919,7 +926,8 @@ link_socket_verify_incoming_addr(struct buffer *buf,
919 919
 {
920 920
     if (buf->len > 0)
921 921
     {
922
-        switch (from_addr->dest.addr.sa.sa_family) {
922
+        switch (from_addr->dest.addr.sa.sa_family)
923
+        {
923 924
             case AF_INET6:
924 925
             case AF_INET:
925 926
                 if (!link_socket_actual_defined(from_addr))
... ...
@@ -269,10 +269,12 @@ static void
269 269
 key_ctx_update_implicit_iv(struct key_ctx *ctx, uint8_t *key, size_t key_len);
270 270
 
271 271
 const tls_cipher_name_pair *
272
-tls_get_cipher_name_pair(const char *cipher_name, size_t len) {
272
+tls_get_cipher_name_pair(const char *cipher_name, size_t len)
273
+{
273 274
     const tls_cipher_name_pair *pair = tls_cipher_name_translation_table;
274 275
 
275
-    while (pair->openssl_name != NULL) {
276
+    while (pair->openssl_name != NULL)
277
+    {
276 278
         if ((strlen(pair->openssl_name) == len && 0 == memcmp(cipher_name, pair->openssl_name, len))
277 279
             || (strlen(pair->iana_name) == len && 0 == memcmp(cipher_name, pair->iana_name, len)))
278 280
         {
... ...
@@ -1068,7 +1070,9 @@ tls_session_init(struct tls_multi *multi, struct tls_session *session)
1068 1068
 
1069 1069
     /* Randomize session # if it is 0 */
1070 1070
     while (!session_id_defined(&session->session_id))
1071
+    {
1071 1072
         session_id_random(&session->session_id);
1073
+    }
1072 1074
 
1073 1075
     /* Are we a TLS server or client? */
1074 1076
     ASSERT(session->opt->key_method >= 1);
... ...
@@ -1130,7 +1134,9 @@ tls_session_free(struct tls_session *session, bool clear)
1130 1130
     free_buf(&session->tls_wrap.work);
1131 1131
 
1132 1132
     for (i = 0; i < KS_SIZE; ++i)
1133
+    {
1133 1134
         key_state_free(&session->key[i], false);
1135
+    }
1134 1136
 
1135 1137
     if (session->common_name)
1136 1138
     {
... ...
@@ -1187,7 +1193,8 @@ reset_session(struct tls_multi *multi, struct tls_session *session)
1187 1187
  * called again.
1188 1188
  */
1189 1189
 static inline void
1190
-compute_earliest_wakeup(interval_t *earliest, interval_t seconds_from_now) {
1190
+compute_earliest_wakeup(interval_t *earliest, interval_t seconds_from_now)
1191
+{
1191 1192
     if (seconds_from_now < *earliest)
1192 1193
     {
1193 1194
         *earliest = seconds_from_now;
... ...
@@ -1357,7 +1364,9 @@ tls_multi_free(struct tls_multi *multi, bool clear)
1357 1357
     free(multi->remote_ciphername);
1358 1358
 
1359 1359
     for (i = 0; i < TM_SIZE; ++i)
1360
+    {
1360 1361
         tls_session_free(&multi->session[i], false);
1362
+    }
1361 1363
 
1362 1364
     if (clear)
1363 1365
     {
... ...
@@ -1705,7 +1714,9 @@ tls1_PRF(const uint8_t *label,
1705 1705
     tls1_P_hash(sha1,S2,len,label,label_len,out2,olen);
1706 1706
 
1707 1707
     for (i = 0; i<olen; i++)
1708
+    {
1708 1709
         out1[i] ^= out2[i];
1710
+    }
1709 1711
 
1710 1712
     secure_memzero(out2, olen);
1711 1713
 
... ...
@@ -1855,7 +1866,8 @@ exit:
1855 1855
 }
1856 1856
 
1857 1857
 static void
1858
-key_ctx_update_implicit_iv(struct key_ctx *ctx, uint8_t *key, size_t key_len) {
1858
+key_ctx_update_implicit_iv(struct key_ctx *ctx, uint8_t *key, size_t key_len)
1859
+{
1859 1860
     const cipher_kt_t *cipher_kt = cipher_ctx_get_cipher_kt(ctx->cipher);
1860 1861
 
1861 1862
     /* Only use implicit IV in AEAD cipher mode, where HMAC key is not used */
... ...
@@ -4058,7 +4070,8 @@ tls_peer_info_ncp_ver(const char *peer_info)
4058 4058
 }
4059 4059
 
4060 4060
 bool
4061
-tls_check_ncp_cipher_list(const char *list) {
4061
+tls_check_ncp_cipher_list(const char *list)
4062
+{
4062 4063
     bool unsupported_cipher_found = false;
4063 4064
 
4064 4065
     ASSERT(list);
... ...
@@ -4203,6 +4216,7 @@ done:
4203 4203
 
4204 4204
 #else  /* if defined(ENABLE_CRYPTO) */
4205 4205
 static void
4206
-dummy(void) {
4206
+dummy(void)
4207
+{
4207 4208
 }
4208 4209
 #endif /* ENABLE_CRYPTO */
... ...
@@ -185,7 +185,8 @@ tls_ctx_set_options(struct tls_root_ctx *ctx, unsigned int ssl_flags)
185 185
 }
186 186
 
187 187
 static const char *
188
-tls_translate_cipher_name(const char *cipher_name) {
188
+tls_translate_cipher_name(const char *cipher_name)
189
+{
189 190
     const tls_cipher_name_pair *pair = tls_get_cipher_name_pair(cipher_name, strlen(cipher_name));
190 191
 
191 192
     if (NULL == pair)
... ...
@@ -222,10 +223,12 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
222 222
 
223 223
     /* Get number of ciphers */
224 224
     for (i = 0, cipher_count = 1; i < ciphers_len; i++)
225
+    {
225 226
         if (ciphers[i] == ':')
226 227
         {
227 228
             cipher_count++;
228 229
         }
230
+    }
229 231
 
230 232
     /* Allocate an array for them */
231 233
     ALLOC_ARRAY_CLEAR(ctx->allowed_ciphers, int, cipher_count+1)
... ...
@@ -833,7 +836,8 @@ tls_version_max(void)
833 833
  *                      Must be a valid pointer.
834 834
  */
835 835
 static void
836
-tls_version_to_major_minor(int tls_ver, int *major, int *minor) {
836
+tls_version_to_major_minor(int tls_ver, int *major, int *minor)
837
+{
837 838
     ASSERT(major);
838 839
     ASSERT(minor);
839 840
 
... ...
@@ -321,7 +321,8 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
321 321
 
322 322
     /* Translate IANA cipher suite names to OpenSSL names */
323 323
     begin_of_cipher = end_of_cipher = 0;
324
-    for (; begin_of_cipher < strlen(ciphers); begin_of_cipher = end_of_cipher) {
324
+    for (; begin_of_cipher < strlen(ciphers); begin_of_cipher = end_of_cipher)
325
+    {
325 326
         end_of_cipher += strcspn(&ciphers[begin_of_cipher], ":");
326 327
         cipher_pair = tls_get_cipher_name_pair(&ciphers[begin_of_cipher], end_of_cipher - begin_of_cipher);
327 328
 
... ...
@@ -90,8 +90,12 @@ tls_deauthenticate(struct tls_multi *multi)
90 90
     {
91 91
         int i, j;
92 92
         for (i = 0; i < TM_SIZE; ++i)
93
+        {
93 94
             for (j = 0; j < KS_SIZE; ++j)
95
+            {
94 96
                 multi->session[i].key[j].authenticated = false;
97
+            }
98
+        }
95 99
     }
96 100
 }
97 101
 
... ...
@@ -248,7 +252,9 @@ cert_hash_free(struct cert_hash_set *chs)
248 248
     {
249 249
         int i;
250 250
         for (i = 0; i < MAX_CERT_DEPTH; ++i)
251
+        {
251 252
             free(chs->ch[i]);
253
+        }
252 254
         free(chs);
253 255
     }
254 256
 }
... ...
@@ -269,10 +269,12 @@ asn1_buf_to_c_string(const mbedtls_asn1_buf *orig, struct gc_arena *gc)
269 269
     char *val;
270 270
 
271 271
     for (i = 0; i < orig->len; ++i)
272
+    {
272 273
         if (orig->p[i] == '\0')
273 274
         {
274 275
             return "ERROR: embedded null value";
275 276
         }
277
+    }
276 278
     val = gc_malloc(orig->len+1, false, gc);
277 279
     memcpy(val, orig->p, orig->len);
278 280
     val[orig->len] = '\0';
... ...
@@ -193,7 +193,8 @@ extract_x509_field_ssl(X509_NAME *x509, const char *field_name, char *out,
193 193
 
194 194
     ASSERT(size > 0);
195 195
     *out = '\0';
196
-    do {
196
+    do
197
+    {
197 198
         lastpos = tmp;
198 199
         tmp = X509_NAME_get_index_by_NID(x509, nid, lastpos);
199 200
     } while (tmp > -1);
... ...
@@ -44,7 +44,8 @@ tls_crypt_buf_overhead(void)
44 44
 
45 45
 void
46 46
 tls_crypt_init_key(struct key_ctx_bi *key, const char *key_file,
47
-                   const char *key_inline, bool tls_server) {
47
+                   const char *key_inline, bool tls_server)
48
+{
48 49
     const int key_direction = tls_server ?
49 50
                               KEY_DIRECTION_NORMAL : KEY_DIRECTION_INVERSE;
50 51
 
... ...
@@ -79,7 +80,8 @@ tls_crypt_adjust_frame_parameters(struct frame *frame)
79 79
 
80 80
 bool
81 81
 tls_crypt_wrap(const struct buffer *src, struct buffer *dst,
82
-               struct crypto_options *opt) {
82
+               struct crypto_options *opt)
83
+{
83 84
     const struct key_ctx *ctx = &opt->key_ctx_bi.encrypt;
84 85
     struct gc_arena gc;
85 86
 
... ...
@@ -694,7 +694,8 @@ init_tun(const char *dev,        /* --dev option */
694 694
              * make sure they do not clash with our virtual subnet.
695 695
              */
696 696
 
697
-            for (curele = local_public; curele; curele = curele->ai_next) {
697
+            for (curele = local_public; curele; curele = curele->ai_next)
698
+            {
698 699
                 if (curele->ai_family == AF_INET)
699 700
                 {
700 701
                     check_addr_clash("local",
... ...
@@ -705,7 +706,8 @@ init_tun(const char *dev,        /* --dev option */
705 705
                 }
706 706
             }
707 707
 
708
-            for (curele = remote_public; curele; curele = curele->ai_next) {
708
+            for (curele = remote_public; curele; curele = curele->ai_next)
709
+            {
709 710
                 if (curele->ai_family == AF_INET)
710 711
                 {
711 712
                     check_addr_clash("remote",
... ...
@@ -1036,7 +1038,8 @@ do_ifconfig(struct tuntap *tt,
1036 1036
         struct buffer out = alloc_buf_gc(64, &gc);
1037 1037
 
1038 1038
         char *top;
1039
-        switch (tt->topology) {
1039
+        switch (tt->topology)
1040
+        {
1040 1041
             case TOP_NET30:
1041 1042
                 top = "net30";
1042 1043
                 break;
... ...
@@ -1835,12 +1838,14 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
1835 1835
 
1836 1836
     /* Prefer IPv6 DNS servers,
1837 1837
      * Android will use the DNS server in the order we specify*/
1838
-    for (int i = 0; i < tt->options.dns6_len; i++) {
1838
+    for (int i = 0; i < tt->options.dns6_len; i++)
1839
+    {
1839 1840
         management_android_control(management, "DNS6SERVER",
1840 1841
                                    print_in6_addr(tt->options.dns6[i], 0, &gc));
1841 1842
     }
1842 1843
 
1843
-    for (int i = 0; i < tt->options.dns_len; i++) {
1844
+    for (int i = 0; i < tt->options.dns_len; i++)
1845
+    {
1844 1846
         management_android_control(management, "DNSSERVER",
1845 1847
                                    print_in_addr_t(tt->options.dns[i], 0, &gc));
1846 1848
     }
... ...
@@ -2254,7 +2259,9 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
2254 2254
     {
2255 2255
         ptr = dev;
2256 2256
         while (*ptr && !isdigit((int) *ptr))
2257
+        {
2257 2258
             ptr++;
2259
+        }
2258 2260
         ppa = atoi(ptr);
2259 2261
     }
2260 2262
 
... ...
@@ -3277,7 +3284,10 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
3277 3277
     {
3278 3278
         /* ensure that dev name is "tap+<digits>" *only* */
3279 3279
         p = &dev[3];
3280
-        while (isdigit(*p) ) p++;
3280
+        while (isdigit(*p) )
3281
+        {
3282
+            p++;
3283
+        }
3281 3284
         if (*p != '\0')
3282 3285
         {
3283 3286
             msg( M_FATAL, "TAP device name must be '--dev tapNNNN'" );
... ...
@@ -5455,7 +5465,9 @@ write_dhcp_u32_array(struct buffer *buf, const int type, const uint32_t *data, c
5455 5455
         buf_write_u8(buf, type);
5456 5456
         buf_write_u8(buf, size);
5457 5457
         for (i = 0; i < len; ++i)
5458
+        {
5458 5459
             buf_write_u32(buf, data[i]);
5460
+        }
5459 5461
     }
5460 5462
 }
5461 5463
 
... ...
@@ -6284,10 +6296,12 @@ ascii2ipset(const char *name)
6284 6284
     int i;
6285 6285
     ASSERT(IPW32_SET_N == SIZE(ipset_names));
6286 6286
     for (i = 0; i < IPW32_SET_N; ++i)
6287
+    {
6287 6288
         if (!strcmp(name, ipset_names[i].short_form))
6288 6289
         {
6289 6290
             return i;
6290 6291
         }
6292
+    }
6291 6293
     return -1;
6292 6294
 }
6293 6295
 
... ...
@@ -569,7 +569,8 @@ win32_keyboard_get(struct win32_signal *ws)
569 569
     if (HANDLE_DEFINED(ws->in.read))
570 570
     {
571 571
         INPUT_RECORD ir;
572
-        do {
572
+        do
573
+        {
573 574
             DWORD n;
574 575
             if (!keyboard_input_available(ws))
575 576
             {
... ...
@@ -681,7 +682,8 @@ win32_pause(struct win32_signal *ws)
681 681
     {
682 682
         int status;
683 683
         msg(M_INFO|M_NOPREFIX, "Press any key to continue...");
684
-        do {
684
+        do
685
+        {
685 686
             status = WaitForSingleObject(ws->in.read, INFINITE);
686 687
         } while (!win32_keyboard_get(ws));
687 688
     }
... ...
@@ -984,7 +986,9 @@ env_block(const struct env_set *es)
984 984
         bool path_seen = false;
985 985
 
986 986
         for (e = es->list; e != NULL; e = e->next)
987
+        {
987 988
             nchars += strlen(e->string) + 1;
989
+        }
988 990
 
989 991
         nchars += strlen(force_path)+1;
990 992
 
... ...
@@ -293,7 +293,8 @@ ServiceStartAutomatic(DWORD dwArgc, LPTSTR *lpszArgv)
293 293
         /*
294 294
          * Loop over each config file
295 295
          */
296
-        do {
296
+        do
297
+        {
297 298
             HANDLE log_handle = NULL;
298 299
             STARTUPINFO start_info;
299 300
             PROCESS_INFORMATION proc_info;
... ...
@@ -215,7 +215,9 @@ AsyncPipeOp(async_op_t op, HANDLE pipe, LPVOID buffer, DWORD size, DWORD count,
215 215
 
216 216
     handles[0] = io_event;
217 217
     for (i = 0; i < count; i++)
218
+    {
218 219
         handles[i + 1] = events[i];
220
+    }
219 221
 
220 222
     res = WaitForMultipleObjects(count + 1, handles, FALSE,
221 223
                                  op == peek ? INFINITE : IO_TIMEOUT);
... ...
@@ -1840,7 +1842,8 @@ ServiceStartInteractive(DWORD dwArgc, LPTSTR *lpszArgv)
1840 1840
     PHANDLE handles = NULL;
1841 1841
     DWORD handle_count;
1842 1842
     BOOL
1843
-    CmpHandle(LPVOID item, LPVOID hnd) {
1843
+    CmpHandle(LPVOID item, LPVOID hnd)
1844
+    {
1844 1845
         return item == hnd;
1845 1846
     }
1846 1847
 
... ...
@@ -78,7 +78,8 @@ searchandreplace(const char *tosearch, const char *searchfor, const char *replac
78 78
         return strdup(tosearch);
79 79
     }
80 80
 
81
-    while (scratch) {
81
+    while (scratch)
82
+    {
82 83
         strncat(temp,searching,scratch-searching);
83 84
         strcat(temp,replacewith);
84 85
 
... ...
@@ -117,7 +118,9 @@ string_array_len(const char *array[])
117 117
     if (array)
118 118
     {
119 119
         while (array[i])
120
+        {
120 121
             ++i;
122
+        }
121 123
     }
122 124
     return i;
123 125
 }
... ...
@@ -116,7 +116,9 @@ string_array_len(const char *array[])
116 116
     if (array)
117 117
     {
118 118
         while (array[i])
119
+        {
119 120
             ++i;
121
+        }
120 122
     }
121 123
     return i;
122 124
 }