]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Remove a number of checks for functions/headers that are always present
authorArne Schwabe <arne@rfc2549.org>
Tue, 6 Apr 2021 16:25:16 +0000 (18:25 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 7 Apr 2021 06:31:08 +0000 (08:31 +0200)
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>
config-msvc.h
configure.ac
src/compat/compat-daemon.c
src/compat/compat-gettimeofday.c
src/openvpn/platform.c
src/openvpn/sig.c
src/openvpn/syshead.h

index 0f5b539fa5405480ca06d3d0e81f7985c04eee21..2d5e1a51ce139b56858bd5aa60f37166a556c454 100644 (file)
@@ -5,7 +5,6 @@
 #define ENABLE_PF 1
 #define ENABLE_CRYPTO_OPENSSL 1
 #define ENABLE_DEBUG 1
-#define ENABLE_EUREPHIA 1
 #define ENABLE_FRAGMENT 1
 #define ENABLE_HTTP_PROXY 1
 #define ENABLE_LZO 1
 #define ENABLE_PORT_SHARE 1
 #define ENABLE_SOCKS 1
 
-#define HAVE_ERRNO_H 1
 #define HAVE_FCNTL_H 1
-#define HAVE_CTYPE_H 1
-#define HAVE_STDARG_H 1
 #define HAVE_STDIO_H 1
 #define HAVE_STDLIB_H 1
-#define HAVE_STRDUP 1
 #define HAVE_STRERROR 1
 #define HAVE_STRINGS_H 1
 #define HAVE_STRING_H 1
@@ -31,8 +26,6 @@
 #define HAVE_SYSTEM 1
 #define HAVE_TIME 1
 #define HAVE_TIME_H 1
-#define HAVE_UNLINK 1
-#define HAVE_VSNPRINTF 1
 #define HAVE_WINDOWS_H 1
 #define HAVE_WINSOCK2_H 1
 #define HAVE_WS2TCPIP_H 1
 #define HAVE_ACCESS 1
 #define HAVE_CHDIR 1
 #define HAVE_CHSIZE 1
-#define HAVE_CTIME 1
 #define HAVE_IN_PKTINFO 1
-#define HAVE_MEMSET 1
-#define HAVE_PUTENV 1
-#define HAVE_STAT 1
 
 #define HAVE_OPENSSL_ENGINE 1
 /* hardcode usage of OpenSSL 1.1.x */
index 07a62ad8fbd6f8dabd18e8a6263a9e87e1a2a32d..81700abcbb36db6b4744842bc6c465eab1f4627e 100644 (file)
@@ -414,10 +414,9 @@ AX_TYPE_SOCKLEN_T
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned long])
 AC_CHECK_HEADERS([ \
-       stdio.h stdarg.h limits.h \
-       time.h errno.h fcntl.h io.h direct.h \
-       ctype.h sys/types.h sys/socket.h \
-       signal.h unistd.h dlfcn.h \
+       fcntl.h io.h direct.h \
+       sys/types.h sys/socket.h \
+       unistd.h dlfcn.h \
        netinet/in.h netinet/in_systm.h \
        netinet/tcp.h arpa/inet.h netdb.h \
        windows.h winsock2.h ws2tcpip.h \
@@ -426,16 +425,14 @@ AC_CHECK_HEADERS([ \
 AC_CHECK_HEADERS([ \
        sys/time.h sys/ioctl.h sys/stat.h \
        sys/mman.h sys/file.h sys/wait.h \
-       unistd.h signal.h libgen.h stropts.h \
+       unistd.h libgen.h stropts.h \
        syslog.h pwd.h grp.h termios.h \
        sys/sockio.h sys/uio.h linux/sockios.h \
        linux/types.h poll.h sys/epoll.h err.h \
 ])
 
 SOCKET_INCLUDES="
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -591,9 +588,7 @@ AC_CHECK_DECLS(
        ,
        [AC_DEFINE([SIGHUP], [1], [SIGHUP replacement])],
        [[
-               #ifdef HAVE_SIGNAL_H
                #include <signal.h>
-               #endif
        ]]
 )
 AC_CHECK_DECLS(
@@ -601,9 +596,7 @@ AC_CHECK_DECLS(
        ,
        [AC_DEFINE([SIGINT], [2], [SIGINT replacement])],
        [[
-               #ifdef HAVE_SIGNAL_H
                #include <signal.h>
-               #endif
        ]]
 )
 AC_CHECK_DECLS(
@@ -611,9 +604,7 @@ AC_CHECK_DECLS(
        ,
        [AC_DEFINE([SIGUSR1], [10], [SIGUSR1 replacement])],
        [[
-               #ifdef HAVE_SIGNAL_H
                #include <signal.h>
-               #endif
        ]]
 )
 AC_CHECK_DECLS(
@@ -621,9 +612,7 @@ AC_CHECK_DECLS(
        ,
        [AC_DEFINE([SIGUSR2], [12], [SIGUSR2 replacement])],
        [[
-               #ifdef HAVE_SIGNAL_H
                #include <signal.h>
-               #endif
        ]]
 )
 AC_CHECK_DECLS(
@@ -631,9 +620,7 @@ AC_CHECK_DECLS(
        ,
        [AC_DEFINE([SIGTERM], [15], [SIGTERM replacement])],
        [[
-               #ifdef HAVE_SIGNAL_H
                #include <signal.h>
-               #endif
        ]]
 )
 
@@ -642,9 +629,8 @@ AC_FUNC_FORK
 AC_CHECK_FUNCS([ \
        daemon chroot getpwnam setuid nice system getpid dup dup2 \
        syslog openlog mlockall getrlimit getgrnam setgid \
-       setgroups stat flock readv writev time gettimeofday \
-       ctime memset vsnprintf strdup \
-       setsid chdir putenv getpeername unlink \
+       setgroups flock readv writev time gettimeofday \
+       setsid chdir getpeername unlink \
        chsize ftruncate execve getpeereid umask basename dirname access \
        epoll_create strsep \
 ])
index 4ef28faf080fc30da51fac25ab6495fa8267bb4e..197bc3f1bbb4fe09043e7ac15817b725ba80ccbc 100644 (file)
@@ -33,9 +33,7 @@
 #include <unistd.h>
 #endif
 
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -49,9 +47,7 @@
 #include <fcntl.h>
 #endif
 
-#ifdef HAVE_ERRNO_H
 #include <errno.h>
-#endif
 
 int
 daemon(int nochdir, int noclose)
index e63c8d7f87fcea1b912344ad9f15055c261bf495..823dfba6aa9b0ac581ea3dff12c432627abc48e8 100644 (file)
@@ -117,9 +117,7 @@ gettimeofday(struct timeval *tv, void *tz)
 
 #else  /* ifdef _WIN32 */
 
-#ifdef HAVE_TIME_H
 #include <time.h>
-#endif
 
 int
 gettimeofday(struct timeval *tv, void *tz)
index 3bf95f843643412fd38aaae40f997309a188d096..45ee5454143cc086b34641995773e2415a477754 100644 (file)
@@ -354,10 +354,8 @@ platform_unlink(const char *filename)
     BOOL ret = DeleteFileW(wide_string(filename, &gc));
     gc_free(&gc);
     return (ret != 0);
-#elif defined(HAVE_UNLINK)
+#else
     return (unlink(filename) == 0);
-#else  /* if defined(_WIN32) */
-    return false;
 #endif
 }
 
index 24a2878fae0d39a14d58fb49a58b96f5b62fb318..3409c3adbe74b90f28838afb6147b8b640018773 100644 (file)
@@ -214,7 +214,6 @@ signal_restart_status(const struct signal_info *si)
 #endif /* ifdef ENABLE_MANAGEMENT */
 }
 
-#ifdef HAVE_SIGNAL_H
 
 /* normal signal handler, when we are in event loop */
 static void
@@ -224,22 +223,18 @@ signal_handler(const int signum)
     signal(signum, signal_handler);
 }
 
-#endif
 
 /* set handlers for unix signals */
 
-#ifdef HAVE_SIGNAL_H
 #define SM_UNDEF     0
 #define SM_PRE_INIT  1
 #define SM_POST_INIT 2
 static int signal_mode; /* GLOBAL */
-#endif
 
 void
 pre_init_signal_catch(void)
 {
 #ifndef _WIN32
-#ifdef HAVE_SIGNAL_H
     signal_mode = SM_PRE_INIT;
     signal(SIGINT, signal_handler);
     signal(SIGTERM, signal_handler);
@@ -247,7 +242,6 @@ pre_init_signal_catch(void)
     signal(SIGUSR1, SIG_IGN);
     signal(SIGUSR2, SIG_IGN);
     signal(SIGPIPE, SIG_IGN);
-#endif /* HAVE_SIGNAL_H */
 #endif /* _WIN32 */
 }
 
@@ -255,7 +249,6 @@ void
 post_init_signal_catch(void)
 {
 #ifndef _WIN32
-#ifdef HAVE_SIGNAL_H
     signal_mode = SM_POST_INIT;
     signal(SIGINT, signal_handler);
     signal(SIGTERM, signal_handler);
@@ -263,7 +256,6 @@ post_init_signal_catch(void)
     signal(SIGUSR1, signal_handler);
     signal(SIGUSR2, signal_handler);
     signal(SIGPIPE, SIG_IGN);
-#endif /* HAVE_SIGNAL_H */
 #endif
 }
 
@@ -271,7 +263,6 @@ post_init_signal_catch(void)
 void
 restore_signal_state(void)
 {
-#ifdef HAVE_SIGNAL_H
     if (signal_mode == SM_PRE_INIT)
     {
         pre_init_signal_catch();
@@ -280,7 +271,6 @@ restore_signal_state(void)
     {
         post_init_signal_catch();
     }
-#endif
 }
 
 /*
index bca71d5cfba6cfd58c1ad93e6bbb5503947f7917..bac07d1026e62288abe96b9e9c7b18e53ac32c16 100644 (file)
@@ -78,9 +78,7 @@
 #include <sys/time.h>
 #endif
 
-#ifdef HAVE_TIME_H
 #include <time.h>
-#endif
 
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #include <sys/file.h>
 #endif
 
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
 /* These headers belong to C99 and should be always be present */
+#include <stdlib.h>
 #include <inttypes.h>
 #include <stdint.h>
-
-#ifdef HAVE_STDARG_H
 #include <stdarg.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SIGNAL_H
 #include <signal.h>
-#endif
-
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
-
-#ifdef HAVE_STDIO_H
 #include <stdio.h>
-#endif
-
-#ifdef HAVE_CTYPE_H
 #include <ctype.h>
-#endif
-
-#ifdef HAVE_ERRNO_H
 #include <errno.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
 #endif
 
 #ifdef HAVE_ERR_H
 #include <strings.h>
 #endif
 #else
-#ifdef HAVE_STRING_H
 #include <string.h>
 #endif
-#endif
 
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>