From: "flichtenheld (Code Review)" Date: Sat, 4 Apr 2026 23:02:31 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <11023d1194144ddfd4aef697365923c4c97fe7bb-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="jXyYUXKduyw="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Hide various functions when unused List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --jXyYUXKduyw= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1611?usp=3Demail to review the following change. Change subject: Hide various functions when unused ...................................................................... Hide various functions when unused Wrap them into the same ifdef as their only user(s). Identified by cppcheck. Change-Id: I81b7168b64c438f759eace1e8f2735891c797bb9 Signed-off-by: Frank Lichtenheld --- M src/openvpn/buffer.c M src/openvpn/buffer.h M src/openvpn/error.c M src/openvpn/error.h M src/openvpn/otime.h M src/openvpn/socket.c M src/openvpn/socket.h M src/openvpn/socket_util.h M src/openvpn/ssl_openssl.c 9 files changed, 23 insertions(+), 10 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/11/1611/1 diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 71f3769..eec91a6 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -589,6 +589,7 @@ return str; } +#ifdef _WIN32 /* * like buf_null_terminate, but operate on strings */ @@ -605,6 +606,7 @@ *(str + len - 1) =3D '\0'; } } +#endif /* * Remove trailing \r and \n chars. diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index aef29de..b4e65ef 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -469,7 +469,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 =3D 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 1198994..62948aa 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 */ diff --git a/src/openvpn/otime.h b/src/openvpn/otime.h index ad79120..84e315b 100644 --- a/src/openvpn/otime.h +++ b/src/openvpn/otime.h @@ -150,6 +150,7 @@ } } +#ifdef SCHEDULE_TEST static inline bool tv_lt(const struct timeval *t1, const struct timeval *t2) { @@ -223,6 +224,7 @@ { return t1->tv_sec =3D=3D t2->tv_sec && t1->tv_usec =3D=3D t2->tv_usec; } +#endif /* ifdef SCHEDULE_TEST */ static inline void tv_delta(struct timeval *dest, const struct timeval *t1, const struct time= val *t2) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 624ce4f..da6f870 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2976,6 +2976,8 @@ return rwflags; } +#if UNIX_SOCK_SUPPORT + void sd_close(socket_descriptor_t *sd) { @@ -2986,8 +2988,6 @@ } } -#if UNIX_SOCK_SUPPORT - /* * code for unix domain sockets */ diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h index cd4e8ed..6196af0 100644 --- a/src/openvpn/socket.h +++ b/src/openvpn/socket.h @@ -365,7 +365,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 a26663a..001470c 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -462,6 +462,7 @@ } } +#ifdef TLS1_3_VERSION static void convert_tls13_list_to_openssl(char *openssl_ciphers, size_t len, const cha= r *ciphers) { @@ -486,6 +487,7 @@ } } } +#endif void tls_ctx_restrict_ciphers_tls13(struct tls_root_ctx *ctx, const char *ciphe= rs) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1611?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I81b7168b64c438f759eace1e8f2735891c797bb9 Gerrit-Change-Number: 1611 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --jXyYUXKduyw= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

Hide various functions when unused

W= rap them into the same ifdef as their only user(s).

Identified by cp= pcheck.

Change-Id: I81b7168b64c438f759eace1e8f2735891c797bb9
Sign= ed-off-by: Frank Lichtenheld <frank@...2641...>
---
M src/openv= pn/buffer.c
M src/openvpn/buffer.h
M src/openvpn/error.c
M src/ope= nvpn/error.h
M src/openvpn/otime.h
M src/openvpn/socket.c
M src/op= envpn/socket.h
M src/openvpn/socket_util.h
M src/openvpn/ssl_openssl.= c
9 files changed, 23 insertions(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/11/161=
1/1
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c=

index 71f3769..eec91a6 100644
--- a/src/openvpn/b= uffer.c
+++ b/src/openvpn/buffer.c
@@ -589,= 6 +589,7 @@
return str;
}
<= span>
+#ifdef _WIN32=
/*
* like buf_null_terminate, but opera= te on strings
*/
@@ -605,6 +606,7 @@
*(str + len - 1) =3D '\0';
= }
}
+#ifdef _WIN32<= br> 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; /* GLOBA= L */

= -/* If true, we forked from main OpenVPN process */
-static bool forked; /* GLOBAL */
= -
/* our default= output targets */
static FILE *default_out; /* GLOBAL */<= /span>
static FILE *default_err; /* GLOBAL */

+/* If true, we forked= from main OpenVPN process */
+static bool forked; /* GLOBAL */
+
+#if PORT_SHARE
void
msg_forked(void)<= /span>
{
forked =3D true;
}=
+#endif

bool
set_debug_level(const int leve= l, const unsigned int flags)
diff --git a/src/openvpn/error= .h b/src/openvpn/error.h
index 1198994..62948aa 100644
--- a/src/openvpn/error.h
+++ b/src/openvpn/err= or.h
@@ -260,8 +260,10 @@
return check= _debug_level(flags) && dont_mute(flags);
}<= br>
+#if PORT_= SHARE
/* Call if we forked */
void msg_fo= rked(void);
+#endif

/* syslog output */

diff --git a/src/openvpn/otime.h b/src/openvpn/otime.h<= br>index ad79120..84e315b 100644
--- a/src/openvpn/ot= ime.h
+++ b/src/openvpn/otime.h
@@ -150,6 += 150,7 @@
}
}
=
+#ifdef SCHEDULE_TEST
static inline bool
tv_lt(const struct timeval = *t1, const struct timeval *t2)
{
@@ -223,6= +224,7 @@
{
return t1->tv_sec =3D= =3D t2->tv_sec && t1->tv_usec =3D=3D t2->tv_usec; }
+#endif /*= ifdef SCHEDULE_TEST */

static inline vo= id
tv_delta(struct timeval *dest, const struct timeval *t1= , const struct timeval *t2)
diff --git a/src/openvpn/socket= .c b/src/openvpn/socket.c
index 624ce4f..da6f870 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/s= ocket.c
@@ -2976,6 +2976,8 @@
return r= wflags;
}

+#if UNIX_SOCK_SUPPORT
+
void
sd_close= (socket_descriptor_t *sd)
{
@@ -2986,8 +29= 88,6 @@
}
}
<= br>-#if UNIX_SOCK_SUPPORT<= br>-
/* * code for unix domain sockets
*/
diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h

index cd4e8ed..6196af0 100644

--- a/src/openvpn/socket.h
+++ b/src/openvpn/socket.h
@@ -365,7 +365,9 = @@

void link_socket_close(struct link_so= cket *sock);

+#ifdef ENABLE_MANAGEMENT
void sd_close(socket_d= escriptor_t *sd);
+#e= ndif

void bad_address_length(int actual,= int expected);

diff --git a/src/openvpn/= socket_util.h b/src/openvpn/socket_util.h
index 13deeaa..13= f5962 100644
--- a/src/openvpn/socket_util.h
+++ b/src/openvpn/socket_util.h

@@ -250,6 +250,7 @@
}
}

+#ifdef TARGET_ANDROID
s= tatic inline bool
addr_local(const struct sockaddr *addr)<= /span>
{
@@ -269,12 +270,12 @@
= return false;
}
}+#endif

-
+#if ENABLE_IP_PKTINFO
stati= c inline bool
addr_defined_ipi(const struct link_socket_ac= tual *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
<= /span>
/*
* Overhead added to packets by variou= s protocols.
diff --git a/src/openvpn/ssl_openssl.c b/src/o= penvpn/ssl_openssl.c
index a26663a..001470c 100644--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/s= sl_openssl.c
@@ -462,6 +462,7 @@
}
}

+#ifdef TLS1_3_VERSION
static void
= convert_tls13_list_to_openssl(char *openssl_ciphers, size_t len, con= st char *ciphers)
{
@@ -486,6 +487,7 @@
}
}
}+#endif

void
tls_ctx_restrict_ciphers_tls13(struct t= ls_root_ctx *ctx, const char *ciphers)

= To view, visit change 1611. To unsubscribe, or for help writing mail filters, v= isit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I81b7168b64c438f759eace1e8f2= 735891c797bb9
Gerrit-Change-Number: 1611
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --jXyYUXKduyw=--