]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Remove a large number of unused structs and functions
authorArne Schwabe <arne@rfc2549.org>
Fri, 18 Oct 2024 06:37:17 +0000 (08:37 +0200)
committerGert Doering <gert@greenie.muc.de>
Fri, 18 Oct 2024 06:40:10 +0000 (08:40 +0200)
These have been found by Clion's Inspect Code functionality and have
been verified by hand.  A few functions like buf_read_u32 have been
kept since they still feel being useful while currently not being used.

Change-Id: I0d96ee06c355c6a5ce082af23921e329d3efae33
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241018063717.14629-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29594.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
23 files changed:
src/openvpn/buffer.c
src/openvpn/buffer.h
src/openvpn/crypto_mbedtls.h
src/openvpn/crypto_openssl.h
src/openvpn/error.h
src/openvpn/fragment.h
src/openvpn/init.c
src/openvpn/manage.c
src/openvpn/manage.h
src/openvpn/misc.h
src/openvpn/mtcp.c
src/openvpn/mtcp.h
src/openvpn/openvpn.h
src/openvpn/packet_id.h
src/openvpn/platform.c
src/openvpn/platform.h
src/openvpn/proto.h
src/openvpn/proxy.h
src/openvpn/ps.h
src/openvpn/shaper.h
src/openvpn/socket.h
tests/unit_tests/openvpn/test_buffer.c
tests/unit_tests/openvpn/test_pkt.c

index 9ee76aa3cdea4a337cf6b55f0719cb15b4bff53a..b2a5bf5b97eeee50b5162ad47c23fdc6eeff4182 100644 (file)
@@ -296,24 +296,6 @@ buf_catrunc(struct buffer *buf, const char *str)
     }
 }
 
-/*
- * convert a multi-line output to one line
- */
-void
-convert_to_one_line(struct buffer *buf)
-{
-    uint8_t *cp = BPTR(buf);
-    int len = BLEN(buf);
-    while (len--)
-    {
-        if (*cp == '\n')
-        {
-            *cp = '|';
-        }
-        ++cp;
-    }
-}
-
 bool
 buffer_write_file(const char *filename, const struct buffer *buf)
 {
index 8a40010bc1a2e822ed80ebdc4e656526999a11da..2f804fb747839ad04f13364869412cbb3b0023b8 100644 (file)
@@ -486,11 +486,6 @@ bool buffer_write_file(const char *filename, const struct buffer *buf);
  */
 void buf_catrunc(struct buffer *buf, const char *str);
 
-/*
- * convert a multi-line output to one line
- */
-void convert_to_one_line(struct buffer *buf);
-
 /*
  * Parse a string based on a given delimiter char
  */
index 48d1e207f0fe55bf07780f7824f36d1c867bd189..a966a7a9d77d48023206231260078667af6d4402 100644 (file)
@@ -75,7 +75,6 @@ typedef mbedtls_operation_t crypto_operation_t;
 #define MD5_DIGEST_LENGTH       16
 #define SHA_DIGEST_LENGTH       20
 #define SHA256_DIGEST_LENGTH    32
-#define DES_KEY_LENGTH 8
 
 /**
  * Returns a singleton instance of the mbed TLS random number generator.
index 4cd988a05ff8894e65dd6aec4546b12949d60d43..288c2fa876fb29ddb85293cd1ae7c6fe3277ea07 100644 (file)
@@ -93,7 +93,6 @@ typedef int crypto_operation_t;
 /** Cipher should decrypt */
 #define OPENVPN_OP_DECRYPT      0
 
-#define DES_KEY_LENGTH 8
 #define MD4_DIGEST_LENGTH       16
 
 /**
index ab2872aedce613936d01d083c20ddb75b75b9c21..9a4577b68390b7275430bc33ce529a5add1a3c19 100644 (file)
@@ -297,10 +297,6 @@ set_check_status_error_delay(unsigned int milliseconds)
 
 extern const char *x_msg_prefix;
 
-void msg_thread_init(void);
-
-void msg_thread_uninit(void);
-
 static inline void
 msg_set_prefix(const char *prefix)
 {
index c3eb2ef920928a9d1c364117affefb0018496662..3cd0ee73ba7bec10c7f43efceb3eca785a81e0c9 100644 (file)
@@ -137,8 +137,6 @@ struct fragment_master {
     struct event_timeout wakeup; /**< Timeout structure used by the main
                                   *   event loop to know when to do
                                   *   fragmentation housekeeping. */
-    bool received_os_mtu_hint;  /**< Whether the operating system has
-                                 *   explicitly recommended an MTU value. */
 #define N_SEQ_ID            256
     /**< One more than the maximum fragment
      *   sequence ID, above which the IDs wrap
index ae911a9fcdaaaa0bdd3a2efc5592ddc8fe4f1eb3..9371024ee697217c8fb17ee68956864aa36be23f 100644 (file)
@@ -816,8 +816,6 @@ init_port_share(struct context *c)
 bool
 init_static(void)
 {
-    /* configure_path (); */
-
 #if defined(DMALLOC)
     crypto_init_dmalloc();
 #endif
index 05b5a1a033997631b2fb8b629b6cff37efe8770b..f296788bef0f6f5b5fcfc759857334fd0bf45bdf 100644 (file)
@@ -3796,16 +3796,6 @@ management_would_hold(struct management *man)
     return (man->settings.flags & MF_HOLD) && !man->persist.hold_release && man_standalone_ok(man);
 }
 
-/*
- * Return true if (from the management interface's perspective) OpenVPN should
- * daemonize.
- */
-bool
-management_should_daemonize(struct management *man)
-{
-    return management_would_hold(man) || (man->settings.flags & MF_QUERY_PASSWORDS);
-}
-
 /*
  * If the hold flag is enabled, hibernate until a management client releases the hold.
  * Return true if the caller should not sleep for an additional time interval.
index 18965108ff473ece84a36025f0a2d34f392c9390..f50154304e895faf4ee1373f6ae6f099348fc8d5 100644 (file)
@@ -390,8 +390,6 @@ int managment_android_persisttun_action(struct management *man);
 
 #endif
 
-bool management_should_daemonize(struct management *man);
-
 bool management_would_hold(struct management *man);
 
 bool management_hold(struct management *man, int holdtime);
index cdfb0de9ae23d8d265d8df09c4761a206b078655..3c46c02e8e431965352b3894e93c7a3c6f99de2f 100644 (file)
@@ -186,9 +186,6 @@ void set_auth_token_user(struct user_pass *tk, const char *username);
  */
 const char *safe_print(const char *str, struct gc_arena *gc);
 
-
-void configure_path(void);
-
 const char *sanitize_control_message(const char *str, struct gc_arena *gc);
 
 /*
index 96408d1196683eeb10b682181d6c705634acb19a..3ae8be7361ffa902923f67e4834839a15dbcdabf 100644 (file)
 
 #define MTCP_N           ((void *)16) /* upper bound on MTCP_x */
 
-struct ta_iow_flags
-{
-    unsigned int flags;
-    unsigned int ret;
-    unsigned int tun;
-    unsigned int sock;
-};
-
 #ifdef ENABLE_DEBUG
 static const char *
 pract(int action)
index 886d2cc10dc053e5f40cdcf48795ceaad847c054..ab968e9be13ac59d7c4052b7253aa03087a963dc 100644 (file)
@@ -58,9 +58,6 @@ bool multi_tcp_instance_specific_init(struct multi_context *m, struct multi_inst
 
 void multi_tcp_instance_specific_free(struct multi_instance *mi);
 
-void multi_tcp_link_out_deferred(struct multi_context *m, struct multi_instance *mi);
-
-
 /**************************************************************************/
 /**
  * Main event loop for OpenVPN in TCP server mode.
index e98c93e9b97887f043ecd0e907f96c0115de2a60..8dfcab47f2db9e82a578af59eae54ddfc5d12451 100644 (file)
@@ -200,10 +200,6 @@ struct context_1
     /**< Hash of option strings received from the
      *   remote OpenVPN server.  Only used in
      *   client-mode. */
-
-    struct user_pass *auth_user_pass;
-    /**< Username and password for
-     *   authentication. */
 };
 
 
index 558361a362f414ac95336e86942d643ac2b602d1..3778d1990aeeddcf8933b27af5c76a912008ba4e 100644 (file)
@@ -318,23 +318,6 @@ packet_id_close_to_wrapping(const struct packet_id_send *p)
     return p->id >= PACKET_ID_WRAP_TRIGGER;
 }
 
-static inline bool
-check_timestamp_delta(time_t remote, unsigned int max_delta)
-{
-    unsigned int abs;
-    const time_t local_now = now;
-
-    if (local_now >= remote)
-    {
-        abs = local_now - remote;
-    }
-    else
-    {
-        abs = remote - local_now;
-    }
-    return abs <= max_delta;
-}
-
 static inline void
 packet_id_reap_test(struct packet_id_rec *p)
 {
index 3d9d59e67b5e2992781710988d3efb7ef0fc6756..d1cb7d1899aebd73cc6e306a63fb204c83d03ec6 100644 (file)
@@ -483,19 +483,6 @@ platform_sleep_milliseconds(unsigned int n)
 #endif
 }
 
-/*
- * Go to sleep indefinitely.
- */
-void
-platform_sleep_until_signal(void)
-{
-#ifdef _WIN32
-    ASSERT(0);
-#else
-    select(0, NULL, NULL, NULL, NULL);
-#endif
-}
-
 /* delete a file, return true if succeeded */
 bool
 platform_unlink(const char *filename)
index 181cb71d14d1458b7d55dee18c887578e81ff527..81c222c7ce24f0c25cc06425081f0d9d677afa20 100644 (file)
@@ -131,13 +131,9 @@ int platform_access(const char *path, int mode);
 
 void platform_sleep_milliseconds(unsigned int n);
 
-void platform_sleep_until_signal(void);
-
 /* delete a file, return true if succeeded */
 bool platform_unlink(const char *filename);
 
-int platform_putenv(char *string);
-
 FILE *platform_fopen(const char *path, const char *mode);
 
 int platform_open(const char *path, int flags, int mode);
index a160fb6f63e0bd90837d0a82e05fb4b92be22657..7b94fbcf5895f19022b368baf32ff09b4b187380 100644 (file)
@@ -83,25 +83,6 @@ struct openvpn_8021qhdr
 #define SIZE_ETH_TO_8021Q_HDR (sizeof(struct openvpn_8021qhdr) \
                                - sizeof(struct openvpn_ethhdr))
 
-
-struct openvpn_arp {
-#define ARP_MAC_ADDR_TYPE 0x0001
-    uint16_t mac_addr_type;     /* 0x0001 */
-
-    uint16_t proto_addr_type;   /* 0x0800 */
-    uint8_t mac_addr_size;      /* 0x06 */
-    uint8_t proto_addr_size;    /* 0x04 */
-
-#define ARP_REQUEST 0x0001
-#define ARP_REPLY   0x0002
-    uint16_t arp_command;       /* 0x0001 for ARP request, 0x0002 for ARP reply */
-
-    uint8_t mac_src[OPENVPN_ETH_ALEN];
-    in_addr_t ip_src;
-    uint8_t mac_dest[OPENVPN_ETH_ALEN];
-    in_addr_t ip_dest;
-};
-
 struct openvpn_iphdr {
 #define OPENVPN_IPH_GET_VER(v) (((v) >> 4) & 0x0F)
 #define OPENVPN_IPH_GET_LEN(v) (((v) & 0x0F) << 2)
index d9e598c600585192d8a56e2b2dfd3f11e2ad29af..1475b87d6f5de64c8724a78208c9382fc28636c6 100644 (file)
@@ -61,12 +61,6 @@ struct http_proxy_options {
     bool nocache;
 };
 
-struct http_proxy_options_simple {
-    const char *server;
-    const char *port;
-    int auth_retry;
-};
-
 struct http_proxy_info {
     bool defined;
     int auth_method;
index f0d4d7d72e3f1d5ff866abfdd4d2a4d4db8308bb..1be29aeb73e8b361f39fde110b4351dd3194aa6d 100644 (file)
@@ -30,8 +30,6 @@
 #include "buffer.h"
 #include "ssl.h"
 
-typedef void (*post_fork_cleanup_func_t)(void *arg);
-
 struct port_share {
     /* Foreground's socket to background process */
     socket_descriptor_t foreground_fd;
index 8eb8db12c7d08c2dc4041bf79179fc96d1656669..4783ebc982ec4a8e097b03da5c6c62a2ffdd95f5 100644 (file)
@@ -89,12 +89,6 @@ shaper_init(struct shaper *s, int bytes_per_second)
     shaper_reset_wakeup(s);
 }
 
-static inline int
-shaper_current_bandwidth(struct shaper *s)
-{
-    return s->bytes_per_second;
-}
-
 /*
  * Returns traffic shaping delay in microseconds relative to current
  * time, or 0 if no delay.
index 2e583af5971fed4556eff6cfa9ce9e5704d19c48..04eb8a421d61be252a9e24c39f4942e25fc9f1d0 100644 (file)
@@ -360,16 +360,6 @@ const char *print_sockaddr_ex(const struct sockaddr *addr,
                               const unsigned int flags,
                               struct gc_arena *gc);
 
-static inline
-const char *
-print_openvpn_sockaddr_ex(const struct openvpn_sockaddr *addr,
-                          const char *separator,
-                          const unsigned int flags,
-                          struct gc_arena *gc)
-{
-    return print_sockaddr_ex(&addr->addr.sa, separator, flags, gc);
-}
-
 static inline
 const char *
 print_openvpn_sockaddr(const struct openvpn_sockaddr *addr,
@@ -771,22 +761,6 @@ addrlist_match(const struct openvpn_sockaddr *a1, const struct addrinfo *addrlis
     return false;
 }
 
-static inline in_addr_t
-addr_host(const struct openvpn_sockaddr *addr)
-{
-    /*
-     * "public" addr returned is checked against ifconfig for
-     * possible clash: non sense for now given
-     * that we do ifconfig only IPv4
-     */
-    if (addr->addr.sa.sa_family != AF_INET)
-    {
-        return 0;
-    }
-    return ntohl(addr->addr.in4.sin_addr.s_addr);
-}
-
-
 static inline bool
 addrlist_port_match(const struct openvpn_sockaddr *a1, const struct addrinfo *a2)
 {
index 6b860b4cd426d8374ccb5ca66c906b561c25a7f8..0fb46973eec837f13e504a6654d37d340c99e449 100644 (file)
@@ -49,7 +49,6 @@ test_buffer_strprefix(void **state)
 #define teststr1 "one"
 #define teststr2 "two"
 #define teststr3 "three"
-#define teststr4 "four"
 
 #define assert_buf_equals_str(buf, str) \
     assert_int_equal(BLEN(buf), strlen(str)); \
index 741c982ac1417c608a969592064418e5d621e7b3..ebffabe792799449f364999ffa68cddb01202e6e 100644 (file)
@@ -69,11 +69,6 @@ print_link_socket_actual(const struct link_socket_actual *act, struct gc_arena *
     return "dummy print_link_socket_actual from unit test";
 }
 
-struct test_pkt_context {
-    struct tls_auth_standalone tas_tls_auth;
-    struct tls_auth_standalone tas_crypt;
-};
-
 const char static_key[] = "<tls-auth>\n"
                           "-----BEGIN OpenVPN Static key V1-----\n"
                           "37268ea8f95d7f71f9fb8fc03770c460\n"