From patchwork Sat Aug 8 13:31:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5219 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:21cf:b0:87d:ab56:3700 with SMTP id t15csp734983mae; Sat, 8 Aug 2026 06:32:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AHgh+Rqq0OLLxzlTxMEvlQRJEkYU6zSmGNL1ZNP/RxpOIUQMX762bAVdNkm9xGE7Y8tZTAR+qWmWuKq827s=@openvpn.net X-Received: by 2002:a05:6820:c0cc:10b0:6b0:4a36:fb2c with SMTP id 006d021491bc7-6b04a36ff97mr1387249eaf.4.1786195939841; Sat, 08 Aug 2026 06:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1786195939; cv=none; d=google.com; s=arc-20260327; b=Mr/sjtHQbEZTaf/5d9bgiC/fTNqpejNJZ8sFErfhRgdUhDSgfiSfB2jSGl8o9IH8a5 cMp1IspMog9vtGeZy63hoYUkZhQu/nxJIizmEC3/eujqHp7Ps5SfiGpbKe1nhpdchAJm NF/RYLlt0hT7Ha8UkfkLkhr2oyzn7Xb1poewAaDIRTSYk3FrR+rKwyco9+q/fVKexBY1 P8wRUkFM7Z3oqs0w3gjcgEMB5erwDTxrQOnyaTfQhiMq79TVI1LH+Fc3Zt9r7ZBIKeDO nuxWQIxmw8DlZhF8/BsJzODlaQRv3VlyLIJ3sAfUwBeFPNl/lBVBZcci/TTqqJmDTk/P AGkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=7n5zpI4hYjk98GIfaCFaDNo2ecL9jpUSQCR1SvyX6vo=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=ph5atRh89o9P2iaIgpev/Y8Zwoe+Gx20cojRqoCmDm/WhaAJnmJiGU1pIBBhrkVT1r Dld9EV8N4a7goqOeCYped3JtUtFRqo6BMksgl75pajpMFvs2SS2548dmWiQtvjiBihl+ 1KoHuBFtaA0jw9aXrU3SMQ2ZXQY3AlVlDWWztIyh0R7zrcN8pQVkMwsV1iueRYd/3QdL 6kJTKl8AMPvqUEAkl2fY0wP+SJbUUsEbEPye2wXCw0jXzWuKHzj2mF13hlOziZDm8ad9 Xk8ZapfRTew0nG/GnVLtIPLe8Ouox62jZO9LCgFG7JzItMfmSt/MiowFlScvAg5xyCPl jE9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="dsn96/hS"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Mnj7mkuL; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=monJtTgr; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 006d021491bc7-6b02c515febsi3983544eaf.74.2026.08.08.06.32.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Aug 2026 06:32:19 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="dsn96/hS"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Mnj7mkuL; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=monJtTgr; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7n5zpI4hYjk98GIfaCFaDNo2ecL9jpUSQCR1SvyX6vo=; b=dsn96/hSEa9OXeb4oL3NRhDU+W 4YFlmjScotCvK8clOTmUM7CTNZiW7a7w5At3NrB+lWBdn7EtKUlICTaRm/bbsmlSIsP17HatFPAqJ WL9/WLThW1K/EOeh75sDITv7kEIEsrSIvovTsg/iSnn+66ELEmfrGsNCx6WVCpdhTU3g=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wsh9p-0000AC-Hb; Sat, 08 Aug 2026 13:32:14 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wsh9o-00009t-G4 for openvpn-devel@lists.sourceforge.net; Sat, 08 Aug 2026 13:32:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: 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=0KJInzbHvG5x1X0x72Eym7ZTUgJcR8OKMf+z75RR6v4=; b=Mnj7mkuLUFOojuMZKzHIw4DVGv iThrRRE8Ads1bqUViRUT0TJdEHDqsDV8s9ecOHLMWr0NCATLEePULEUHeQJqrMeB/RK7s/5FwxjaV Lp0hzwrmZC0DcyMl4WP6/wb8AjK+QhY9JkwvOAW0pMLHBf+cqvhhfEj/VzxoZmmVEDBY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: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=0KJInzbHvG5x1X0x72Eym7ZTUgJcR8OKMf+z75RR6v4=; b=monJtTgrJXqzM1Cty3D+T+5LPG 31ya6URpZMd6+kmAw5uh5Ho/OpvoL4RuWWekBhWx8e2mx4FHkg0MvJFAXUB5p/LSJlMD/IStdP6VA mOWsCp2wgFwevoqFd9YUZPt7az2ssNADYue3GG2ddQgDtXKIcM8JiuLj+TLZr+UtYNV0=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wsh9r-0003Q0-2U for openvpn-devel@lists.sourceforge.net; Sat, 08 Aug 2026 13:32:13 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 678DW4ha006151 for ; Sat, 8 Aug 2026 15:32:04 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 678DW4V3006150 for openvpn-devel@lists.sourceforge.net; Sat, 8 Aug 2026 15:32:04 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sat, 8 Aug 2026 15:31:58 +0200 Message-ID: <20260808133204.6139-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld Wrap them into the same ifdef as their only user(s). Identified by cppcheck. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1wsh9r-0003Q0-2U Subject: [Openvpn-devel] [PATCH v12] Hide various functions when unused 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1872962193714854911 X-GMAIL-MSGID: 1872962193714854911 From: Frank Lichtenheld Wrap them into the same ifdef as their only user(s). Identified by cppcheck. Change-Id: I81b7168b64c438f759eace1e8f2735891c797bb9 Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1611 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1611 This mail reflects revision 12 of this Change. Acked-by according to Gerrit (reflected above): Arne Schwabe diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 5f2b233..922238d 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -594,6 +594,7 @@ return str; } +#ifdef _WIN32 /* * like buf_null_terminate, but operate on strings */ @@ -610,6 +611,7 @@ *(str + len - 1) = '\0'; } } +#endif /* * Remove trailing \r and \n chars. diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index 833ae6f..c6722c7 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -470,7 +470,9 @@ const char *skip_leading_whitespace(const char *str); +#ifdef _WIN32 void string_null_terminate(char *str, int len, int capacity); +#endif /** * Write buffer contents to file. diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 2900352..26d4c7c 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -84,18 +84,20 @@ /* If non-null, messages should be written here (used for debugging only) */ static FILE *msgfp; /* GLOBAL */ -/* If true, we forked from main OpenVPN process */ -static bool forked; /* GLOBAL */ - /* our default output targets */ static FILE *default_out; /* GLOBAL */ static FILE *default_err; /* GLOBAL */ +/* If true, we forked from main OpenVPN process */ +static bool forked; /* GLOBAL */ + +#if PORT_SHARE void msg_forked(void) { forked = true; } +#endif bool set_debug_level(const int level, const unsigned int flags) diff --git a/src/openvpn/error.h b/src/openvpn/error.h index 3b742d7..45826a2 100644 --- a/src/openvpn/error.h +++ b/src/openvpn/error.h @@ -260,8 +260,10 @@ return check_debug_level(flags) && dont_mute(flags); } +#if PORT_SHARE /* Call if we forked */ void msg_forked(void); +#endif /* syslog output */ @@ -393,12 +395,14 @@ return false; } +#if defined(ENABLE_CRYPTO_OPENSSL) /** Convert fatal errors to nonfatal, don't touch other errors */ static inline msglvl_t nonfatal(const msglvl_t err) { return (err & M_FATAL) ? (err ^ M_FATAL) | M_NONFATAL : err; } +#endif static inline int openvpn_errno_maybe_crt(bool *crt_error) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 8bcc332..0f66ad51 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2961,6 +2961,8 @@ return rwflags; } +#if UNIX_SOCK_SUPPORT + void sd_close(socket_descriptor_t *sd) { @@ -2971,8 +2973,6 @@ } } -#if UNIX_SOCK_SUPPORT - /* * code for unix domain sockets */ diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h index b490610..1a532e1 100644 --- a/src/openvpn/socket.h +++ b/src/openvpn/socket.h @@ -366,7 +366,9 @@ void link_socket_close(struct link_socket *sock); +#ifdef ENABLE_MANAGEMENT void sd_close(socket_descriptor_t *sd); +#endif void bad_address_length(int actual, int expected); diff --git a/src/openvpn/socket_util.h b/src/openvpn/socket_util.h index 13deeaa..13f5962 100644 --- a/src/openvpn/socket_util.h +++ b/src/openvpn/socket_util.h @@ -250,6 +250,7 @@ } } +#ifdef TARGET_ANDROID static inline bool addr_local(const struct sockaddr *addr) { @@ -269,12 +270,12 @@ return false; } } +#endif - +#if ENABLE_IP_PKTINFO static inline bool addr_defined_ipi(const struct link_socket_actual *lsa) { -#if ENABLE_IP_PKTINFO if (!lsa) { return 0; @@ -296,11 +297,9 @@ default: return 0; } -#else /* if ENABLE_IP_PKTINFO */ - ASSERT(0); -#endif return false; } +#endif /* * Overhead added to packets by various protocols. diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index 32b13db..e4b760e 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -436,6 +436,7 @@ } } +#ifdef TLS1_3_VERSION static void convert_tls13_list_to_openssl(char *openssl_ciphers, size_t len, const char *ciphers) { @@ -460,6 +461,7 @@ } } } +#endif void tls_ctx_restrict_ciphers_tls13(struct tls_root_ctx *ctx, const char *ciphers) diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/openvpn/test_pkcs11.c index 8b6e594..042bd8b 100644 --- a/tests/unit_tests/openvpn/test_pkcs11.c +++ b/tests/unit_tests/openvpn/test_pkcs11.c @@ -45,6 +45,7 @@ struct management *management; /* global */ +#if defined(ENABLE_CRYPTO_OPENSSL) /* replacement for crypto_print_openssl_errors() */ void crypto_print_openssl_errors(const unsigned int flags) @@ -55,6 +56,7 @@ msg(flags, "OpenSSL error %lu: %s", e, ERR_error_string(e, NULL)); } } +#endif /* stubs for some unused functions instead of pulling in too many dependencies */ int