From patchwork Tue Apr 6 06:25:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1718 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.27.255.7]) by backend30.mail.ord1d.rsapps.net with LMTP id WENEObaLbGAZdAAAIUCqbw (envelope-from ) for ; Tue, 06 Apr 2021 12:26:30 -0400 Received: from proxy1.mail.iad3a.rsapps.net ([172.27.255.7]) by director8.mail.ord1d.rsapps.net with LMTP id UHEFObaLbGCgcAAAfY0hYg (envelope-from ) for ; Tue, 06 Apr 2021 12:26:30 -0400 Received: from smtp38.gate.iad3a ([172.27.255.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.iad3a.rsapps.net with LMTPS id 4IMoMraLbGCcDgAA8TVjwQ (envelope-from ) for ; Tue, 06 Apr 2021 12:26:30 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp38.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: d77617c2-96f4-11eb-82fe-525400000c92-1-1 Received: from [216.105.38.7] ([216.105.38.7:56110] helo=lists.sourceforge.net) by smtp38.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 39/B1-20246-6BB8C606; Tue, 06 Apr 2021 12:26:30 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lToWX-0000mz-QW; Tue, 06 Apr 2021 16:25:53 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lToWK-0000jH-5h for openvpn-devel@lists.sourceforge.net; Tue, 06 Apr 2021 16:25:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Cnr4n7J3gCtuCFv+hr+ZNxIKxOfd/Q5MpVxmkUPNxTQ=; b=cBU0uKGG9XXO/1gdzto6/EdGlY evpH/K/lhO8MPnbT9x2i2oG60NCjhxlGmvsyIlRu0EQ942BGMRw4Rr+GJl3XZFaQHehBRVulGu6q1 oyJdB1Gn29SIx5jzsiGpMmlxsPxnFxHDHx+ZkQK6JnCFx1lMElpWS8JY/yxLpdAxH+RY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Cnr4n7J3gCtuCFv+hr+ZNxIKxOfd/Q5MpVxmkUPNxTQ=; b=a9tZLGjhIVZPIcI2QHQ4wlYlwS X4cLPdpqJpZCb+V1261WW+5pWyoeB38GO3Cs4ZK+SQ9ZgdQ/vpSfdHa9ZyQqC+VDn1N3nlVwhBET9 eNyHodYztf2F4/cxMFYaX1SKyWgyebOXnwe4odw4zD7/AehmtUs4KW3Q2uJPc/qEibU8=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1lToW8-00BauS-B5 for openvpn-devel@lists.sourceforge.net; Tue, 06 Apr 2021 16:25:39 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lToVy-0003r4-CZ for openvpn-devel@lists.sourceforge.net; Tue, 06 Apr 2021 18:25:18 +0200 Received: (nullmailer pid 4130 invoked by uid 10006); Tue, 06 Apr 2021 16:25:18 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Tue, 6 Apr 2021 18:25:16 +0200 Message-Id: <20210406162518.4075-3-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210406162518.4075-1-arne@rfc2549.org> References: <20210406162518.4075-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1lToW8-00BauS-B5 Subject: [Openvpn-devel] [PATCH 3/5] Remove a number of checks for functions/headers that are always present X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox 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 Acked-by: Gert Doering --- config-msvc.h | 11 ----------- configure.ac | 26 ++++++------------------- src/compat/compat-daemon.c | 4 ---- src/compat/compat-gettimeofday.c | 2 -- src/openvpn/platform.c | 4 +--- src/openvpn/sig.c | 10 ---------- src/openvpn/syshead.h | 33 ++++---------------------------- 7 files changed, 11 insertions(+), 79 deletions(-) diff --git a/config-msvc.h b/config-msvc.h index 0f5b539fa..2d5e1a51c 100644 --- a/config-msvc.h +++ b/config-msvc.h @@ -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 @@ -17,13 +16,9 @@ #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 @@ -47,11 +40,7 @@ #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 */ diff --git a/configure.ac b/configure.ac index 07a62ad8f..81700abcb 100644 --- a/configure.ac +++ b/configure.ac @@ -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 -#endif #ifdef HAVE_SYS_TYPES_H #include #endif @@ -591,9 +588,7 @@ AC_CHECK_DECLS( , [AC_DEFINE([SIGHUP], [1], [SIGHUP replacement])], [[ - #ifdef HAVE_SIGNAL_H #include - #endif ]] ) AC_CHECK_DECLS( @@ -601,9 +596,7 @@ AC_CHECK_DECLS( , [AC_DEFINE([SIGINT], [2], [SIGINT replacement])], [[ - #ifdef HAVE_SIGNAL_H #include - #endif ]] ) AC_CHECK_DECLS( @@ -611,9 +604,7 @@ AC_CHECK_DECLS( , [AC_DEFINE([SIGUSR1], [10], [SIGUSR1 replacement])], [[ - #ifdef HAVE_SIGNAL_H #include - #endif ]] ) AC_CHECK_DECLS( @@ -621,9 +612,7 @@ AC_CHECK_DECLS( , [AC_DEFINE([SIGUSR2], [12], [SIGUSR2 replacement])], [[ - #ifdef HAVE_SIGNAL_H #include - #endif ]] ) AC_CHECK_DECLS( @@ -631,9 +620,7 @@ AC_CHECK_DECLS( , [AC_DEFINE([SIGTERM], [15], [SIGTERM replacement])], [[ - #ifdef HAVE_SIGNAL_H #include - #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 \ ]) diff --git a/src/compat/compat-daemon.c b/src/compat/compat-daemon.c index 4ef28faf0..197bc3f1b 100644 --- a/src/compat/compat-daemon.c +++ b/src/compat/compat-daemon.c @@ -33,9 +33,7 @@ #include #endif -#ifdef HAVE_STDLIB_H #include -#endif #ifdef HAVE_SYS_TYPES_H #include @@ -49,9 +47,7 @@ #include #endif -#ifdef HAVE_ERRNO_H #include -#endif int daemon(int nochdir, int noclose) diff --git a/src/compat/compat-gettimeofday.c b/src/compat/compat-gettimeofday.c index e63c8d7f8..823dfba6a 100644 --- a/src/compat/compat-gettimeofday.c +++ b/src/compat/compat-gettimeofday.c @@ -117,9 +117,7 @@ gettimeofday(struct timeval *tv, void *tz) #else /* ifdef _WIN32 */ -#ifdef HAVE_TIME_H #include -#endif int gettimeofday(struct timeval *tv, void *tz) diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index 3bf95f843..45ee54541 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -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 } diff --git a/src/openvpn/sig.c b/src/openvpn/sig.c index 24a2878fa..3409c3adb 100644 --- a/src/openvpn/sig.c +++ b/src/openvpn/sig.c @@ -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 } /* diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index bca71d5cf..bac07d102 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -78,9 +78,7 @@ #include #endif -#ifdef HAVE_TIME_H #include -#endif #ifdef HAVE_SYS_SOCKET_H #include @@ -114,40 +112,19 @@ #include #endif -#ifdef HAVE_STDLIB_H -#include -#endif - /* These headers belong to C99 and should be always be present */ +#include #include #include - -#ifdef HAVE_STDARG_H #include -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_SIGNAL_H #include -#endif - -#ifdef HAVE_LIMITS_H #include -#endif - -#ifdef HAVE_STDIO_H #include -#endif - -#ifdef HAVE_CTYPE_H #include -#endif - -#ifdef HAVE_ERRNO_H #include + +#ifdef HAVE_UNISTD_H +#include #endif #ifdef HAVE_ERR_H @@ -199,10 +176,8 @@ #include #endif #else -#ifdef HAVE_STRING_H #include #endif -#endif #ifdef HAVE_ARPA_INET_H #include