Browse code

make function declarations C99 compliant

In the attempt of adhering to the C99 standard as much as possible,
ensure that all the function declarations with no parameter contain
the "void" keyword[1].

Defects identified with sparse[2].

[1] ISO/IEC 9899:1999 spec, TC3 - section 6.7.5.3
[1] https://sparse.wiki.kernel.org/index.php/Main_Page

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20170811090744.31750-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15203.html
Signed-off-by: David Sommerseth <davids@openvpn.net>

Antonio Quartulli authored on 2017/08/11 18:07:40
Showing 27 changed files
... ...
@@ -180,7 +180,7 @@ buf_assign(struct buffer *dest, const struct buffer *src)
180 180
 }
181 181
 
182 182
 struct buffer
183
-clear_buf()
183
+clear_buf(void)
184 184
 {
185 185
     struct buffer buf;
186 186
     CLEAR(buf);
... ...
@@ -44,7 +44,7 @@ struct _query_user query_user[QUERY_USER_NUMSLOTS];  /* GLOBAL */
44 44
 
45 45
 
46 46
 void
47
-query_user_clear()
47
+query_user_clear(void)
48 48
 {
49 49
     int i;
50 50
 
... ...
@@ -46,7 +46,7 @@ extern struct _query_user query_user[];  /**< Global variable, declared in conso
46 46
  * Wipes all data put into all of the query_user structs
47 47
  *
48 48
  */
49
-void query_user_clear();
49
+void query_user_clear(void);
50 50
 
51 51
 
52 52
 /**
... ...
@@ -72,7 +72,7 @@ void query_user_add(char *prompt, size_t prompt_len,
72 72
  *
73 73
  * @return True if executing all the defined steps completed successfully
74 74
  */
75
-bool query_user_exec_builtin();
75
+bool query_user_exec_builtin(void);
76 76
 
77 77
 
78 78
 #if defined(ENABLE_SYSTEMD)
... ...
@@ -83,7 +83,7 @@ bool query_user_exec_builtin();
83 83
  *
84 84
  * @return True if executing all the defined steps completed successfully
85 85
  */
86
-bool query_user_exec();
86
+bool query_user_exec(void);
87 87
 
88 88
 #else  /* ENABLE_SYSTEMD not defined*/
89 89
 /**
... ...
@@ -92,7 +92,7 @@ bool query_user_exec();
92 92
  *
93 93
  */
94 94
 static bool
95
-query_user_exec()
95
+query_user_exec(void)
96 96
 {
97 97
     return query_user_exec_builtin();
98 98
 }
... ...
@@ -267,7 +267,7 @@ get_console_input(const char *prompt, const bool echo, char *input, const int ca
267 267
  *
268 268
  */
269 269
 bool
270
-query_user_exec_builtin()
270
+query_user_exec_builtin(void)
271 271
 {
272 272
     bool ret = true; /* Presume everything goes okay */
273 273
     int i;
... ...
@@ -41,7 +41,7 @@
41 41
  */
42 42
 
43 43
 static bool
44
-check_systemd_running()
44
+check_systemd_running(void)
45 45
 {
46 46
     struct stat c;
47 47
 
... ...
@@ -95,7 +95,7 @@ get_console_input_systemd(const char *prompt, const bool echo, char *input, cons
95 95
  *
96 96
  */
97 97
 bool
98
-query_user_exec()
98
+query_user_exec(void)
99 99
 {
100 100
     bool ret = true;  /* Presume everything goes okay */
101 101
     int i;
... ...
@@ -1693,7 +1693,7 @@ static int nonce_secret_len = 0; /* GLOBAL */
1693 1693
 
1694 1694
 /* Reset the nonce value, also done periodically to refresh entropy */
1695 1695
 static void
1696
-prng_reset_nonce()
1696
+prng_reset_nonce(void)
1697 1697
 {
1698 1698
     const int size = md_kt_size(nonce_md) + nonce_secret_len;
1699 1699
 #if 1 /* Must be 1 for real usage */
... ...
@@ -1772,7 +1772,7 @@ prng_bytes(uint8_t *output, int len)
1772 1772
 
1773 1773
 /* an analogue to the random() function, but use prng_bytes */
1774 1774
 long int
1775
-get_random()
1775
+get_random(void)
1776 1776
 {
1777 1777
     long int l;
1778 1778
     prng_bytes((unsigned char *)&l, sizeof(l));
... ...
@@ -453,7 +453,7 @@ void prng_init(const char *md_name, const int nonce_secret_len_parm);
453 453
  */
454 454
 void prng_bytes(uint8_t *output, int len);
455 455
 
456
-void prng_uninit();
456
+void prng_uninit(void);
457 457
 
458 458
 void test_crypto(struct crypto_options *co, struct frame *f);
459 459
 
... ...
@@ -159,7 +159,7 @@ print_cipher(const cipher_kt_t *info)
159 159
 }
160 160
 
161 161
 void
162
-show_available_ciphers()
162
+show_available_ciphers(void)
163 163
 {
164 164
     const int *ciphers = mbedtls_cipher_list();
165 165
 
... ...
@@ -196,7 +196,7 @@ show_available_ciphers()
196 196
 }
197 197
 
198 198
 void
199
-show_available_digests()
199
+show_available_digests(void)
200 200
 {
201 201
     const int *digests = mbedtls_md_list();
202 202
 
... ...
@@ -223,7 +223,7 @@ show_available_digests()
223 223
 }
224 224
 
225 225
 void
226
-show_available_engines()
226
+show_available_engines(void)
227 227
 {
228 228
     printf("Sorry, mbed TLS hardware crypto engine functionality is not "
229 229
            "available\n");
... ...
@@ -243,7 +243,7 @@ show_available_engines()
243 243
  * entropy gathering function.
244 244
  */
245 245
 mbedtls_ctr_drbg_context *
246
-rand_ctx_get()
246
+rand_ctx_get(void)
247 247
 {
248 248
     static mbedtls_entropy_context ec = {0};
249 249
     static mbedtls_ctr_drbg_context cd_ctx = {0};
... ...
@@ -280,7 +280,7 @@ rand_ctx_get()
280 280
 
281 281
 #ifdef ENABLE_PREDICTION_RESISTANCE
282 282
 void
283
-rand_ctx_enable_prediction_resistance()
283
+rand_ctx_enable_prediction_resistance(void)
284 284
 {
285 285
     mbedtls_ctr_drbg_context *cd_ctx = rand_ctx_get();
286 286
 
... ...
@@ -85,13 +85,13 @@ typedef mbedtls_md_context_t hmac_ctx_t;
85 85
  * added. During initialisation, a personalisation string will be added based
86 86
  * on the time, the PID, and a pointer to the random context.
87 87
  */
88
-mbedtls_ctr_drbg_context *rand_ctx_get();
88
+mbedtls_ctr_drbg_context *rand_ctx_get(void);
89 89
 
90 90
 #ifdef ENABLE_PREDICTION_RESISTANCE
91 91
 /**
92 92
  * Enable prediction resistance on the random number generator.
93 93
  */
94
-void rand_ctx_enable_prediction_resistance();
94
+void rand_ctx_enable_prediction_resistance(void);
95 95
 
96 96
 #endif
97 97
 
... ...
@@ -280,7 +280,7 @@ print_cipher(const EVP_CIPHER *cipher)
280 280
 }
281 281
 
282 282
 void
283
-show_available_ciphers()
283
+show_available_ciphers(void)
284 284
 {
285 285
     int nid;
286 286
     size_t i;
... ...
@@ -339,7 +339,7 @@ show_available_ciphers()
339 339
 }
340 340
 
341 341
 void
342
-show_available_digests()
342
+show_available_digests(void)
343 343
 {
344 344
     int nid;
345 345
 
... ...
@@ -364,7 +364,7 @@ show_available_digests()
364 364
 }
365 365
 
366 366
 void
367
-show_available_engines()
367
+show_available_engines(void)
368 368
 {
369 369
 #if HAVE_OPENSSL_ENGINE /* Only defined for OpenSSL */
370 370
     ENGINE *e;
... ...
@@ -159,7 +159,7 @@ set_machine_readable_output(bool parsable)
159 159
 }
160 160
 
161 161
 void
162
-error_reset()
162
+error_reset(void)
163 163
 {
164 164
     use_syslog = std_redir = false;
165 165
     suppress_timestamps = false;
... ...
@@ -480,7 +480,7 @@ open_syslog(const char *pgmname, bool stdio_to_null)
480 480
 }
481 481
 
482 482
 void
483
-close_syslog()
483
+close_syslog(void)
484 484
 {
485 485
 #if SYSLOG_CAPABILITY
486 486
     if (use_syslog)
... ...
@@ -635,7 +635,7 @@ unsigned int x_cs_verbose_level; /* GLOBAL */
635 635
 unsigned int x_cs_err_delay_ms;  /* GLOBAL */
636 636
 
637 637
 void
638
-reset_check_status()
638
+reset_check_status(void)
639 639
 {
640 640
     x_cs_info_level = 0;
641 641
     x_cs_verbose_level = 0;
... ...
@@ -261,7 +261,7 @@ void msg_forked(void);
261 261
 
262 262
 void open_syslog(const char *pgmname, bool stdio_to_null);
263 263
 
264
-void close_syslog();
264
+void close_syslog(void);
265 265
 
266 266
 /* log file output */
267 267
 void redirect_stdout_stderr(const char *file, bool append);
... ...
@@ -1917,7 +1917,7 @@ do_close_tun(struct context *c, bool force)
1917 1917
 }
1918 1918
 
1919 1919
 void
1920
-tun_abort()
1920
+tun_abort(void)
1921 1921
 {
1922 1922
     struct context *c = static_context;
1923 1923
     if (c)
... ...
@@ -155,7 +155,7 @@ event_timeout_clear(struct event_timeout *et)
155 155
 }
156 156
 
157 157
 static inline struct event_timeout
158
-event_timeout_clear_ret()
158
+event_timeout_clear_ret(void)
159 159
 {
160 160
     struct event_timeout ret;
161 161
     event_timeout_clear(&ret);
... ...
@@ -68,7 +68,7 @@ static void man_output_standalone(struct management *man, volatile int *signal_r
68 68
 static void man_reset_client_socket(struct management *man, const bool exiting);
69 69
 
70 70
 static void
71
-man_help()
71
+man_help(void)
72 72
 {
73 73
     msg(M_CLIENT, "Management Interface for %s", title_string);
74 74
     msg(M_CLIENT, "Commands:");
... ...
@@ -31,7 +31,7 @@
31 31
  */
32 32
 
33 33
 static inline int
34
-occ_reset_op()
34
+occ_reset_op(void)
35 35
 {
36 36
     return -1;
37 37
 }
... ...
@@ -643,7 +643,7 @@ packet_id_debug_print(int msglevel,
643 643
 #ifdef PID_TEST
644 644
 
645 645
 void
646
-packet_id_interactive_test()
646
+packet_id_interactive_test(void)
647 647
 {
648 648
     struct packet_id pid;
649 649
     struct packet_id_net pin;
... ...
@@ -299,7 +299,7 @@ packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *
299 299
 const char *packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc);
300 300
 
301 301
 #ifdef PID_TEST
302
-void packet_id_interactive_test();
302
+void packet_id_interactive_test(void);
303 303
 
304 304
 #endif
305 305
 
... ...
@@ -356,7 +356,7 @@ cleanup:
356 356
 }
357 357
 
358 358
 void
359
-pkcs11_terminate()
359
+pkcs11_terminate(void)
360 360
 {
361 361
     dmsg(
362 362
         D_PKCS11_DEBUG,
... ...
@@ -422,13 +422,13 @@ pkcs11_addProvider(
422 422
 }
423 423
 
424 424
 int
425
-pkcs11_logout()
425
+pkcs11_logout(void)
426 426
 {
427 427
     return pkcs11h_logout() == CKR_OK;
428 428
 }
429 429
 
430 430
 int
431
-pkcs11_management_id_count()
431
+pkcs11_management_id_count(void)
432 432
 {
433 433
     pkcs11h_certificate_id_list_t id_list = NULL;
434 434
     pkcs11h_certificate_id_list_t t = NULL;
... ...
@@ -173,7 +173,7 @@ platform_nice(int niceval)
173 173
 
174 174
 /* Get current PID */
175 175
 unsigned int
176
-platform_getpid()
176
+platform_getpid(void)
177 177
 {
178 178
 #ifdef _WIN32
179 179
     return (unsigned int) GetCurrentProcessId();
... ...
@@ -172,7 +172,7 @@ send_control(const socket_descriptor_t fd, int code)
172 172
 }
173 173
 
174 174
 static int
175
-cmsg_size()
175
+cmsg_size(void)
176 176
 {
177 177
     return CMSG_SPACE(sizeof(socket_descriptor_t));
178 178
 }
... ...
@@ -347,7 +347,7 @@ tls_init_control_channel_frame_parameters(const struct frame *data_channel_frame
347 347
 }
348 348
 
349 349
 void
350
-init_ssl_lib()
350
+init_ssl_lib(void)
351 351
 {
352 352
     tls_init_lib();
353 353
 
... ...
@@ -355,7 +355,7 @@ init_ssl_lib()
355 355
 }
356 356
 
357 357
 void
358
-free_ssl_lib()
358
+free_ssl_lib(void)
359 359
 {
360 360
     crypto_uninit_lib();
361 361
     prng_uninit();
... ...
@@ -88,17 +88,17 @@ int pem_password_callback(char *buf, int size, int rwflag, void *u);
88 88
  * Perform any static initialisation necessary by the library.
89 89
  * Called on OpenVPN initialisation
90 90
  */
91
-void tls_init_lib();
91
+void tls_init_lib(void);
92 92
 
93 93
 /**
94 94
  * Free any global SSL library-specific data structures.
95 95
  */
96
-void tls_free_lib();
96
+void tls_free_lib(void);
97 97
 
98 98
 /**
99 99
  * Clear the underlying SSL library's error state.
100 100
  */
101
-void tls_clear_error();
101
+void tls_clear_error(void);
102 102
 
103 103
 /**
104 104
  * Parse a TLS version specifier
... ...
@@ -63,17 +63,17 @@
63 63
 #include <mbedtls/sha256.h>
64 64
 
65 65
 void
66
-tls_init_lib()
66
+tls_init_lib(void)
67 67
 {
68 68
 }
69 69
 
70 70
 void
71
-tls_free_lib()
71
+tls_free_lib(void)
72 72
 {
73 73
 }
74 74
 
75 75
 void
76
-tls_clear_error()
76
+tls_clear_error(void)
77 77
 {
78 78
 }
79 79
 
... ...
@@ -69,7 +69,7 @@
69 69
 int mydata_index; /* GLOBAL */
70 70
 
71 71
 void
72
-tls_init_lib()
72
+tls_init_lib(void)
73 73
 {
74 74
     SSL_library_init();
75 75
 #ifndef ENABLE_SMALL
... ...
@@ -82,7 +82,7 @@ tls_init_lib()
82 82
 }
83 83
 
84 84
 void
85
-tls_free_lib()
85
+tls_free_lib(void)
86 86
 {
87 87
     EVP_cleanup();
88 88
 #ifndef ENABLE_SMALL
... ...
@@ -91,7 +91,7 @@ tls_free_lib()
91 91
 }
92 92
 
93 93
 void
94
-tls_clear_error()
94
+tls_clear_error(void)
95 95
 {
96 96
     ERR_clear_error();
97 97
 }
... ...
@@ -1329,7 +1329,7 @@ static time_t biofp_last_open;                 /* GLOBAL */
1329 1329
 static const int biofp_reopen_interval = 600;  /* GLOBAL */
1330 1330
 
1331 1331
 static void
1332
-close_biofp()
1332
+close_biofp(void)
1333 1333
 {
1334 1334
     if (biofp)
1335 1335
     {
... ...
@@ -1339,7 +1339,7 @@ close_biofp()
1339 1339
 }
1340 1340
 
1341 1341
 static void
1342
-open_biofp()
1342
+open_biofp(void)
1343 1343
 {
1344 1344
     const time_t current = time(NULL);
1345 1345
     const pid_t pid = getpid();
... ...
@@ -1775,7 +1775,7 @@ show_available_tls_ciphers(const char *cipher_list)
1775 1775
  * in the OpenSSL library.
1776 1776
  */
1777 1777
 void
1778
-show_available_curves()
1778
+show_available_curves(void)
1779 1779
 {
1780 1780
 #ifndef OPENSSL_NO_EC
1781 1781
     EC_builtin_curve *curves = NULL;
... ...
@@ -1235,7 +1235,7 @@ set_win_sys_path_via_env(struct env_set *es)
1235 1235
 
1236 1236
 
1237 1237
 const char *
1238
-win_get_tempdir()
1238
+win_get_tempdir(void)
1239 1239
 {
1240 1240
     static char tmpdir[MAX_PATH];
1241 1241
     WCHAR wtmpdir[MAX_PATH];
... ...
@@ -1398,7 +1398,7 @@ win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel)
1398 1398
 }
1399 1399
 
1400 1400
 int
1401
-win32_version_info()
1401
+win32_version_info(void)
1402 1402
 {
1403 1403
     if (!IsWindowsXPOrGreater())
1404 1404
     {
... ...
@@ -1426,7 +1426,7 @@ win32_version_info()
1426 1426
 }
1427 1427
 
1428 1428
 bool
1429
-win32_is_64bit()
1429
+win32_is_64bit(void)
1430 1430
 {
1431 1431
 #if defined(_WIN64)
1432 1432
     return true;  /* 64-bit programs run only on Win64 */
... ...
@@ -285,7 +285,7 @@ char *get_win_sys_path(void);
285 285
 void fork_to_self(const char *cmdline);
286 286
 
287 287
 /* Find temporary directory */
288
-const char *win_get_tempdir();
288
+const char *win_get_tempdir(void);
289 289
 
290 290
 /* Convert a string from UTF-8 to UCS-2 */
291 291
 WCHAR *wide_string(const char *utf8, struct gc_arena *gc);
... ...
@@ -299,7 +299,7 @@ bool win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel);
299 299
 #define WIN_7 2
300 300
 #define WIN_8 3
301 301
 
302
-int win32_version_info();
302
+int win32_version_info(void);
303 303
 
304 304
 /*
305 305
  * String representation of Windows version number and name, see