Change in openvpn[master]: Hide various functions when unused
A message that is not in the archive (sent off-list or not yet received): gerrit.1775343746000.I81b7168b64c438f759eace1e8f2735891c797bb9@...2715...
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=email
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.
---
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
src/openvpn/buffer.c +2 -0
@@ -589,6 +589,7 @@return str; } +#ifdef _WIN32/* * like buf_null_terminate, but operate on strings */
@@ -605,6 +606,7 @@ *(str + len - 1) = '\0'; } } +#endif /* * Remove trailing \r and \n chars.
src/openvpn/buffer.h +2 -0
@@ -469,7 +469,9 @@const char *skip_leading_whitespace (const char *str); +#ifdef _WIN32void string_null_terminate (char *str,int len,int capacity); +#endif /** * Write buffer contents to file.
src/openvpn/error.c +5 -3
@@ -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)
src/openvpn/error.h +2 -0
@@ -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 */
src/openvpn/otime.h +2 -0
@@ -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 == t2->tv_sec && t1->tv_usec == t2->tv_usec; } +#endif /* ifdef SCHEDULE_TEST */ static inline void tv_delta (struct timeval *dest,const struct timeval *t1,const struct timeval *t2)
src/openvpn/socket.c +2 -2
@@ -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 */
src/openvpn/socket.h +2 -0
@@ -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);
src/openvpn/socket_util.h +4 -5
@@ -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.
src/openvpn/ssl_openssl.c +2 -0
@@ -462,6 +462,7 @@ } } +#ifdef TLS1_3_VERSION static void convert_tls13_list_to_openssl (char *openssl_ciphers,size_t len,const char *ciphers) {
@@ -486,6 +487,7 @@ } } } +#endif void tls_ctx_restrict_ciphers_tls13 (struct tls_root_ctx *ctx,const char *ciphers)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1611?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I81b7168b64c438f759eace1e8f2735891c797bb9
Gerrit-Change-Number: 1611
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1611?usp=email
to look at the new patch set (#4).
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.
---
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
M tests/unit_tests/openvpn/test_pkcs11.c
10 files changed, 27 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/11/1611/4
src/openvpn/buffer.c +2 -0
@@ -589,6 +589,7 @@return str; } +#ifdef _WIN32/* * like buf_null_terminate, but operate on strings */
@@ -605,6 +606,7 @@ *(str + len - 1) = '\0'; } } +#endif /* * Remove trailing \r and \n chars.
src/openvpn/buffer.h +2 -0
@@ -469,7 +469,9 @@const char *skip_leading_whitespace (const char *str); +#ifdef _WIN32void string_null_terminate (char *str,int len,int capacity); +#endif /** * Write buffer contents to file.
src/openvpn/error.c +5 -3
@@ -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)
src/openvpn/error.h +4 -0
@@ -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)
src/openvpn/otime.h +2 -0
@@ -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 == t2->tv_sec && t1->tv_usec == t2->tv_usec; } +#endif /* ifdef SCHEDULE_TEST */ static inline void tv_delta (struct timeval *dest,const struct timeval *t1,const struct timeval *t2)
src/openvpn/socket.c +2 -2
@@ -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 */
src/openvpn/socket.h +2 -0
@@ -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);
src/openvpn/socket_util.h +4 -5
@@ -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.
src/openvpn/ssl_openssl.c +2 -0
@@ -462,6 +462,7 @@ } } +#ifdef TLS1_3_VERSION static void convert_tls13_list_to_openssl (char *openssl_ciphers,size_t len,const char *ciphers) {
@@ -486,6 +487,7 @@ } } } +#endif void tls_ctx_restrict_ciphers_tls13 (struct tls_root_ctx *ctx,const char *ciphers)
tests/unit_tests/openvpn/test_pkcs11.c +2 -0
@@ -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
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1611?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I81b7168b64c438f759eace1e8f2735891c797bb9
Gerrit-Change-Number: 1611
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>