Browse code

Remove a number of checks for functions/headers that are always present

For the unlink function we actually have code that just ignores
the unlink call if the unlink function is not present. But all
platforms should have an unlink function.

This also removes all conditionals check for the headers that
belong to the C99 standard library header list
(https://en.cppreference.com/w/c/header).

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210406162518.4075-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22053.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Arne Schwabe authored on 2021/04/07 01:25:16
Showing 7 changed files
... ...
@@ -5,7 +5,6 @@
5 5
 #define ENABLE_PF 1
6 6
 #define ENABLE_CRYPTO_OPENSSL 1
7 7
 #define ENABLE_DEBUG 1
8
-#define ENABLE_EUREPHIA 1
9 8
 #define ENABLE_FRAGMENT 1
10 9
 #define ENABLE_HTTP_PROXY 1
11 10
 #define ENABLE_LZO 1
... ...
@@ -17,13 +16,9 @@
17 17
 #define ENABLE_PORT_SHARE 1
18 18
 #define ENABLE_SOCKS 1
19 19
 
20
-#define HAVE_ERRNO_H 1
21 20
 #define HAVE_FCNTL_H 1
22
-#define HAVE_CTYPE_H 1
23
-#define HAVE_STDARG_H 1
24 21
 #define HAVE_STDIO_H 1
25 22
 #define HAVE_STDLIB_H 1
26
-#define HAVE_STRDUP 1
27 23
 #define HAVE_STRERROR 1
28 24
 #define HAVE_STRINGS_H 1
29 25
 #define HAVE_STRING_H 1
... ...
@@ -31,8 +26,6 @@
31 31
 #define HAVE_SYSTEM 1
32 32
 #define HAVE_TIME 1
33 33
 #define HAVE_TIME_H 1
34
-#define HAVE_UNLINK 1
35
-#define HAVE_VSNPRINTF 1
36 34
 #define HAVE_WINDOWS_H 1
37 35
 #define HAVE_WINSOCK2_H 1
38 36
 #define HAVE_WS2TCPIP_H 1
... ...
@@ -47,11 +40,7 @@
47 47
 #define HAVE_ACCESS 1
48 48
 #define HAVE_CHDIR 1
49 49
 #define HAVE_CHSIZE 1
50
-#define HAVE_CTIME 1
51 50
 #define HAVE_IN_PKTINFO 1
52
-#define HAVE_MEMSET 1
53
-#define HAVE_PUTENV 1
54
-#define HAVE_STAT 1
55 51
 
56 52
 #define HAVE_OPENSSL_ENGINE 1
57 53
 /* hardcode usage of OpenSSL 1.1.x */
... ...
@@ -414,10 +414,9 @@ AX_TYPE_SOCKLEN_T
414 414
 AC_CHECK_SIZEOF([unsigned int])
415 415
 AC_CHECK_SIZEOF([unsigned long])
416 416
 AC_CHECK_HEADERS([ \
417
-	stdio.h stdarg.h limits.h \
418
-	time.h errno.h fcntl.h io.h direct.h \
419
-	ctype.h sys/types.h sys/socket.h \
420
-	signal.h unistd.h dlfcn.h \
417
+	fcntl.h io.h direct.h \
418
+	sys/types.h sys/socket.h \
419
+	unistd.h dlfcn.h \
421 420
 	netinet/in.h netinet/in_systm.h \
422 421
 	netinet/tcp.h arpa/inet.h netdb.h \
423 422
 	windows.h winsock2.h ws2tcpip.h \
... ...
@@ -426,16 +425,14 @@ AC_CHECK_HEADERS([ \
426 426
 AC_CHECK_HEADERS([ \
427 427
 	sys/time.h sys/ioctl.h sys/stat.h \
428 428
 	sys/mman.h sys/file.h sys/wait.h \
429
-	unistd.h signal.h libgen.h stropts.h \
429
+	unistd.h libgen.h stropts.h \
430 430
 	syslog.h pwd.h grp.h termios.h \
431 431
 	sys/sockio.h sys/uio.h linux/sockios.h \
432 432
 	linux/types.h poll.h sys/epoll.h err.h \
433 433
 ])
434 434
 
435 435
 SOCKET_INCLUDES="
436
-#ifdef HAVE_STDLIB_H
437 436
 #include <stdlib.h>
438
-#endif
439 437
 #ifdef HAVE_SYS_TYPES_H
440 438
 #include <sys/types.h>
441 439
 #endif
... ...
@@ -591,9 +588,7 @@ AC_CHECK_DECLS(
591 591
 	,
592 592
 	[AC_DEFINE([SIGHUP], [1], [SIGHUP replacement])],
593 593
 	[[
594
-		#ifdef HAVE_SIGNAL_H
595 594
 		#include <signal.h>
596
-		#endif
597 595
 	]]
598 596
 )
599 597
 AC_CHECK_DECLS(
... ...
@@ -601,9 +596,7 @@ AC_CHECK_DECLS(
601 601
 	,
602 602
 	[AC_DEFINE([SIGINT], [2], [SIGINT replacement])],
603 603
 	[[
604
-		#ifdef HAVE_SIGNAL_H
605 604
 		#include <signal.h>
606
-		#endif
607 605
 	]]
608 606
 )
609 607
 AC_CHECK_DECLS(
... ...
@@ -611,9 +604,7 @@ AC_CHECK_DECLS(
611 611
 	,
612 612
 	[AC_DEFINE([SIGUSR1], [10], [SIGUSR1 replacement])],
613 613
 	[[
614
-		#ifdef HAVE_SIGNAL_H
615 614
 		#include <signal.h>
616
-		#endif
617 615
 	]]
618 616
 )
619 617
 AC_CHECK_DECLS(
... ...
@@ -621,9 +612,7 @@ AC_CHECK_DECLS(
621 621
 	,
622 622
 	[AC_DEFINE([SIGUSR2], [12], [SIGUSR2 replacement])],
623 623
 	[[
624
-		#ifdef HAVE_SIGNAL_H
625 624
 		#include <signal.h>
626
-		#endif
627 625
 	]]
628 626
 )
629 627
 AC_CHECK_DECLS(
... ...
@@ -631,9 +620,7 @@ AC_CHECK_DECLS(
631 631
 	,
632 632
 	[AC_DEFINE([SIGTERM], [15], [SIGTERM replacement])],
633 633
 	[[
634
-		#ifdef HAVE_SIGNAL_H
635 634
 		#include <signal.h>
636
-		#endif
637 635
 	]]
638 636
 )
639 637
 
... ...
@@ -642,9 +629,8 @@ AC_FUNC_FORK
642 642
 AC_CHECK_FUNCS([ \
643 643
 	daemon chroot getpwnam setuid nice system getpid dup dup2 \
644 644
 	syslog openlog mlockall getrlimit getgrnam setgid \
645
-	setgroups stat flock readv writev time gettimeofday \
646
-	ctime memset vsnprintf strdup \
647
-	setsid chdir putenv getpeername unlink \
645
+	setgroups flock readv writev time gettimeofday \
646
+	setsid chdir getpeername unlink \
648 647
 	chsize ftruncate execve getpeereid umask basename dirname access \
649 648
 	epoll_create strsep \
650 649
 ])
... ...
@@ -33,9 +33,7 @@
33 33
 #include <unistd.h>
34 34
 #endif
35 35
 
36
-#ifdef HAVE_STDLIB_H
37 36
 #include <stdlib.h>
38
-#endif
39 37
 
40 38
 #ifdef HAVE_SYS_TYPES_H
41 39
 #include <sys/types.h>
... ...
@@ -49,9 +47,7 @@
49 49
 #include <fcntl.h>
50 50
 #endif
51 51
 
52
-#ifdef HAVE_ERRNO_H
53 52
 #include <errno.h>
54
-#endif
55 53
 
56 54
 int
57 55
 daemon(int nochdir, int noclose)
... ...
@@ -117,9 +117,7 @@ gettimeofday(struct timeval *tv, void *tz)
117 117
 
118 118
 #else  /* ifdef _WIN32 */
119 119
 
120
-#ifdef HAVE_TIME_H
121 120
 #include <time.h>
122
-#endif
123 121
 
124 122
 int
125 123
 gettimeofday(struct timeval *tv, void *tz)
... ...
@@ -354,10 +354,8 @@ platform_unlink(const char *filename)
354 354
     BOOL ret = DeleteFileW(wide_string(filename, &gc));
355 355
     gc_free(&gc);
356 356
     return (ret != 0);
357
-#elif defined(HAVE_UNLINK)
357
+#else
358 358
     return (unlink(filename) == 0);
359
-#else  /* if defined(_WIN32) */
360
-    return false;
361 359
 #endif
362 360
 }
363 361
 
... ...
@@ -214,7 +214,6 @@ signal_restart_status(const struct signal_info *si)
214 214
 #endif /* ifdef ENABLE_MANAGEMENT */
215 215
 }
216 216
 
217
-#ifdef HAVE_SIGNAL_H
218 217
 
219 218
 /* normal signal handler, when we are in event loop */
220 219
 static void
... ...
@@ -224,22 +223,18 @@ signal_handler(const int signum)
224 224
     signal(signum, signal_handler);
225 225
 }
226 226
 
227
-#endif
228 227
 
229 228
 /* set handlers for unix signals */
230 229
 
231
-#ifdef HAVE_SIGNAL_H
232 230
 #define SM_UNDEF     0
233 231
 #define SM_PRE_INIT  1
234 232
 #define SM_POST_INIT 2
235 233
 static int signal_mode; /* GLOBAL */
236
-#endif
237 234
 
238 235
 void
239 236
 pre_init_signal_catch(void)
240 237
 {
241 238
 #ifndef _WIN32
242
-#ifdef HAVE_SIGNAL_H
243 239
     signal_mode = SM_PRE_INIT;
244 240
     signal(SIGINT, signal_handler);
245 241
     signal(SIGTERM, signal_handler);
... ...
@@ -247,7 +242,6 @@ pre_init_signal_catch(void)
247 247
     signal(SIGUSR1, SIG_IGN);
248 248
     signal(SIGUSR2, SIG_IGN);
249 249
     signal(SIGPIPE, SIG_IGN);
250
-#endif /* HAVE_SIGNAL_H */
251 250
 #endif /* _WIN32 */
252 251
 }
253 252
 
... ...
@@ -255,7 +249,6 @@ void
255 255
 post_init_signal_catch(void)
256 256
 {
257 257
 #ifndef _WIN32
258
-#ifdef HAVE_SIGNAL_H
259 258
     signal_mode = SM_POST_INIT;
260 259
     signal(SIGINT, signal_handler);
261 260
     signal(SIGTERM, signal_handler);
... ...
@@ -263,7 +256,6 @@ post_init_signal_catch(void)
263 263
     signal(SIGUSR1, signal_handler);
264 264
     signal(SIGUSR2, signal_handler);
265 265
     signal(SIGPIPE, SIG_IGN);
266
-#endif /* HAVE_SIGNAL_H */
267 266
 #endif
268 267
 }
269 268
 
... ...
@@ -271,7 +263,6 @@ post_init_signal_catch(void)
271 271
 void
272 272
 restore_signal_state(void)
273 273
 {
274
-#ifdef HAVE_SIGNAL_H
275 274
     if (signal_mode == SM_PRE_INIT)
276 275
     {
277 276
         pre_init_signal_catch();
... ...
@@ -280,7 +271,6 @@ restore_signal_state(void)
280 280
     {
281 281
         post_init_signal_catch();
282 282
     }
283
-#endif
284 283
 }
285 284
 
286 285
 /*
... ...
@@ -78,9 +78,7 @@
78 78
 #include <sys/time.h>
79 79
 #endif
80 80
 
81
-#ifdef HAVE_TIME_H
82 81
 #include <time.h>
83
-#endif
84 82
 
85 83
 #ifdef HAVE_SYS_SOCKET_H
86 84
 #include <sys/socket.h>
... ...
@@ -114,40 +112,19 @@
114 114
 #include <sys/file.h>
115 115
 #endif
116 116
 
117
-#ifdef HAVE_STDLIB_H
118
-#include <stdlib.h>
119
-#endif
120
-
121 117
 /* These headers belong to C99 and should be always be present */
118
+#include <stdlib.h>
122 119
 #include <inttypes.h>
123 120
 #include <stdint.h>
124
-
125
-#ifdef HAVE_STDARG_H
126 121
 #include <stdarg.h>
127
-#endif
128
-
129
-#ifdef HAVE_UNISTD_H
130
-#include <unistd.h>
131
-#endif
132
-
133
-#ifdef HAVE_SIGNAL_H
134 122
 #include <signal.h>
135
-#endif
136
-
137
-#ifdef HAVE_LIMITS_H
138 123
 #include <limits.h>
139
-#endif
140
-
141
-#ifdef HAVE_STDIO_H
142 124
 #include <stdio.h>
143
-#endif
144
-
145
-#ifdef HAVE_CTYPE_H
146 125
 #include <ctype.h>
147
-#endif
148
-
149
-#ifdef HAVE_ERRNO_H
150 126
 #include <errno.h>
127
+
128
+#ifdef HAVE_UNISTD_H
129
+#include <unistd.h>
151 130
 #endif
152 131
 
153 132
 #ifdef HAVE_ERR_H
... ...
@@ -199,10 +176,8 @@
199 199
 #include <strings.h>
200 200
 #endif
201 201
 #else
202
-#ifdef HAVE_STRING_H
203 202
 #include <string.h>
204 203
 #endif
205
-#endif
206 204
 
207 205
 #ifdef HAVE_ARPA_INET_H
208 206
 #include <arpa/inet.h>