]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
ensure function declarations are compiled with their definitions
authorAntonio Quartulli <antonio@openvpn.net>
Sat, 11 Nov 2017 16:18:36 +0000 (00:18 +0800)
committerGert Doering <gert@greenie.muc.de>
Sat, 6 Oct 2018 16:00:48 +0000 (18:00 +0200)
Function prototypes should be included when compiling their
definitions so that it is clear to compilers and static
analyzers that they are not static.

This means that several declarations have to be moved to the
related header files which in turn have to be included by the
source files implementing them.

Generally speaking this also improves the coding style and
makes this code more consistent with the rest that already
follows this rule.

Cc: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171111161836.23356-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15820.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
17 files changed:
src/openvpn/crypto.h
src/openvpn/error.c
src/openvpn/forward.h
src/openvpn/fragment.c
src/openvpn/gremlin.c
src/openvpn/init.h
src/openvpn/lladdr.c
src/openvpn/manage.h
src/openvpn/mbuf.h
src/openvpn/misc.h
src/openvpn/mroute.h
src/openvpn/multi.h
src/openvpn/occ.h
src/openvpn/pf.h
src/openvpn/ping.h
src/openvpn/plugin.h
src/openvpn/socket.h

index 0dc597f297115a8c5c14e9d0ff0f2faf79ff0584..f4b3dca3556bad0603dd6df52d765da11b4a33ad 100644 (file)
@@ -462,6 +462,9 @@ void prng_bytes(uint8_t *output, int len);
 
 void prng_uninit(void);
 
+/* an analogue to the random() function, but use prng_bytes */
+long int get_random(void);
+
 void test_crypto(struct crypto_options *co, struct frame *f);
 
 
index d270ecb8b4699d104075482d0ae95bccae8ce407..51294687bb78716795e7d001c9812d26e7c09c20 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "error.h"
 #include "buffer.h"
+#include "init.h"
 #include "misc.h"
 #include "win32.h"
 #include "socket.h"
@@ -734,13 +735,6 @@ openvpn_exit(const int status)
 {
     if (!forked)
     {
-        void tun_abort();
-
-#ifdef ENABLE_PLUGIN
-        void plugin_abort(void);
-
-#endif
-
         tun_abort();
 
 #ifdef _WIN32
index d8ffe60f36bd1ef4205e660aadbc1c5a4ff9b498..58b75d6469ce7a5ed1e81cdf489ed6165494f7e4 100644 (file)
 
 #define IOW_READ            (IOW_READ_TUN|IOW_READ_LINK)
 
+extern counter_type link_read_bytes_global;
+
+extern counter_type link_write_bytes_global;
+
+void check_tls_dowork(struct context *c);
+
+void check_tls_errors_co(struct context *c);
+
+void check_tls_errors_nco(struct context *c);
+
+#if P2MP
+void check_incoming_control_channel_dowork(struct context *c);
+
+void check_scheduled_exit_dowork(struct context *c);
+
+void check_push_request_dowork(struct context *c);
+#endif /* P2MP */
+
+#ifdef ENABLE_FRAGMENT
+void check_fragment_dowork(struct context *c);
+#endif /* ENABLE_FRAGMENT */
+
+void check_connection_established_dowork(struct context *c);
+
+void check_add_routes_dowork(struct context *c);
+
+void check_inactivity_timeout_dowork(struct context *c);
+
+void check_server_poll_timeout_dowork(struct context *c);
+
+void check_status_file_dowork(struct context *c);
+
+void io_wait_dowork(struct context *c, const unsigned int flags);
 
 void pre_select(struct context *c);
 
index 4eb1dd2893bd89e759613f5453dd888068b6c822..3f0ec2fa0732b5739473829c0517d6cce482568c 100644 (file)
@@ -31,6 +31,7 @@
 
 #ifdef ENABLE_FRAGMENT
 
+#include "crypto.h"
 #include "misc.h"
 #include "fragment.h"
 #include "integer.h"
index 114cb198d30fc051dd80f2a9c035bf170162d9a5..3f2bded621a87bd674d55f20d8db5161d27e4a27 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "error.h"
 #include "common.h"
+#include "crypto.h"
 #include "misc.h"
 #include "otime.h"
 #include "gremlin.h"
index c8ebe768da1b5479e1525f7fa1c150e64f79d000..085ac533adec97493902b1592611c0a6e1496197 100644 (file)
@@ -140,4 +140,6 @@ void open_plugins(struct context *c, const bool import_options, int init_point);
 
 #endif
 
+void tun_abort(void);
+
 #endif /* ifndef INIT_H */
index f24596b5067d886b0fce8dede2aa870be8760cf2..e6b26fc96680c5fb134d9361ff17c9b245068586 100644 (file)
@@ -12,6 +12,7 @@
 #include "error.h"
 #include "misc.h"
 #include "run_command.h"
+#include "lladdr.h"
 
 int
 set_lladdr(const char *ifname, const char *lladdr,
index df01a9ac0299b187d0274220ece0555139e07935..ff143fc1aa67c6b424563356a2e28b598332c52e 100644 (file)
@@ -582,17 +582,17 @@ management_bytes_in(struct management *man, const int size)
 
 #ifdef MANAGEMENT_DEF_AUTH
 
+void man_bytecount_output_server(struct management *man,
+                                 const counter_type *bytes_in_total,
+                                 const counter_type *bytes_out_total,
+                                 struct man_def_auth_context *mdac);
+
 static inline void
 management_bytes_server(struct management *man,
                         const counter_type *bytes_in_total,
                         const counter_type *bytes_out_total,
                         struct man_def_auth_context *mdac)
 {
-    void man_bytecount_output_server(struct management *man,
-                                     const counter_type *bytes_in_total,
-                                     const counter_type *bytes_out_total,
-                                     struct man_def_auth_context *mdac);
-
     if (man->connection.bytecount_update_seconds > 0
         && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds
         && (mdac->flags & (DAF_CONNECTION_ESTABLISHED|DAF_CONNECTION_CLOSED)) == DAF_CONNECTION_ESTABLISHED)
index 4912c958301086f46c969c8d18107c27d385737f..f37563dff84d6affbc9ee9c0a7c8b1ba6c16a316 100644 (file)
@@ -96,11 +96,11 @@ mbuf_maximum_queued(const struct mbuf_set *ms)
     return (int) ms->max_queued;
 }
 
+struct multi_instance *mbuf_peek_dowork(struct mbuf_set *ms);
+
 static inline struct multi_instance *
 mbuf_peek(struct mbuf_set *ms)
 {
-    struct multi_instance *mbuf_peek_dowork(struct mbuf_set *ms);
-
     if (mbuf_defined(ms))
     {
         return mbuf_peek_dowork(ms);
index 14abb0f31e9e96c19bdf0fcc22177f6b00f727a5..9d4601f0542fe2cb972ec7d82e4b2dec1ad4ee9e 100644 (file)
@@ -52,9 +52,6 @@ const char **make_arg_array(const char *first, const char *parms, struct gc_aren
 
 const char **make_extended_arg_array(char **p, struct gc_arena *gc);
 
-/* an analogue to the random() function, but use OpenSSL functions if available */
-long int get_random(void);
-
 /* prepend a random prefix to hostname */
 const char *hostname_randomize(const char *hostname, struct gc_arena *gc);
 
index 1063a187106310fefcffa33e43d716f30bf22010..7fcd9956610d040436b86871aa2b5f3ac34ab3bd 100644 (file)
@@ -170,6 +170,16 @@ void mroute_helper_add_iroute46(struct mroute_helper *mh, int netbits);
 
 void mroute_helper_del_iroute46(struct mroute_helper *mh, int netbits);
 
+unsigned int mroute_extract_addr_ip(struct mroute_addr *src,
+                                    struct mroute_addr *dest,
+                                    const struct buffer *buf);
+
+unsigned int mroute_extract_addr_ether(struct mroute_addr *src,
+                                       struct mroute_addr *dest,
+                                       struct mroute_addr *esrc,
+                                       struct mroute_addr *edest,
+                                       const struct buffer *buf);
+
 /*
  * Given a raw packet in buf, return the src and dest
  * addresses of the packet.
@@ -182,16 +192,6 @@ mroute_extract_addr_from_packet(struct mroute_addr *src,
                                 const struct buffer *buf,
                                 int tunnel_type)
 {
-    unsigned int mroute_extract_addr_ip(struct mroute_addr *src,
-                                     struct mroute_addr *dest,
-                                     const struct buffer *buf);
-
-    unsigned int mroute_extract_addr_ether(struct mroute_addr *src,
-                                           struct mroute_addr *dest,
-                                           struct mroute_addr *esrc,
-                                           struct mroute_addr *edest,
-                                           const struct buffer *buf);
-
     unsigned int ret = 0;
     verify_align_4(buf);
     if (tunnel_type == DEV_TYPE_TUN)
index d7e5c2981175da45c9501cfe29b17dbd86cdbfda..3d3d687545f5974b05a50f1eec8e9879dac97870 100644 (file)
@@ -536,11 +536,12 @@ clear_prefix(void)
  */
 #define MULTI_CACHE_ROUTE_TTL 60
 
+void multi_reap_process_dowork(const struct multi_context *m);
+void multi_process_per_second_timers_dowork(struct multi_context *m);
+
 static inline void
 multi_reap_process(const struct multi_context *m)
 {
-    void multi_reap_process_dowork(const struct multi_context *m);
-
     if (m->reaper->last_call != now)
     {
         multi_reap_process_dowork(m);
@@ -552,8 +553,6 @@ multi_process_per_second_timers(struct multi_context *m)
 {
     if (m->per_second_trigger != now)
     {
-        void multi_process_per_second_timers_dowork(struct multi_context *m);
-
         multi_process_per_second_timers_dowork(m);
         m->per_second_trigger = now;
     }
index 28c25fcd7295ae6f7896fcdaffff2c3a718627b2..e3abd8cb0a235d8edf03c6de01476f5919a58d5d 100644 (file)
@@ -90,6 +90,16 @@ is_occ_msg(const struct buffer *buf)
 
 void process_received_occ_msg(struct context *c);
 
+void check_send_occ_req_dowork(struct context *c);
+
+void check_send_occ_load_test_dowork(struct context *c);
+
+void check_send_occ_msg_dowork(struct context *c);
+
+/*
+ * Inline functions
+ */
+
 static inline int
 occ_reset_op(void)
 {
@@ -102,8 +112,6 @@ occ_reset_op(void)
 static inline void
 check_send_occ_req(struct context *c)
 {
-    void check_send_occ_req_dowork(struct context *c);
-
     if (event_timeout_defined(&c->c2.occ_interval)
         && event_timeout_trigger(&c->c2.occ_interval,
                                  &c->c2.timeval,
@@ -119,8 +127,6 @@ check_send_occ_req(struct context *c)
 static inline void
 check_send_occ_load_test(struct context *c)
 {
-    void check_send_occ_load_test_dowork(struct context *c);
-
     if (event_timeout_defined(&c->c2.occ_mtu_load_test_interval)
         && event_timeout_trigger(&c->c2.occ_mtu_load_test_interval,
                                  &c->c2.timeval,
@@ -136,8 +142,6 @@ check_send_occ_load_test(struct context *c)
 static inline void
 check_send_occ_msg(struct context *c)
 {
-    void check_send_occ_msg_dowork(struct context *c);
-
     if (c->c2.occ_op >= 0)
     {
         if (!TO_LINK_DEF(c))
index 416126a3173ef17d0b947194dd5ef8f36dc77f97..c64d21bdc4fae6e9f3bb34df9a13743194d06b75 100644 (file)
@@ -121,6 +121,10 @@ pf_addr_test(const struct pf_context *src_pf, const struct context *src,
     }
 }
 
+/*
+ * Inline functions
+ */
+
 bool pf_cn_test(struct pf_set *pfs, const struct tls_multi *tm, const int type,
                 const char *prefix);
 
index 441a12b195a7dfd97d0fc72d69e688667f42dafd..a196b32b0cd13585c95840aa84915c36c3f5555e 100644 (file)
@@ -43,6 +43,10 @@ is_ping_msg(const struct buffer *buf)
     return buf_string_match(buf, ping_string, PING_STRING_SIZE);
 }
 
+void check_ping_restart_dowork(struct context *c);
+
+void check_ping_send_dowork(struct context *c);
+
 /*
  * Should we exit or restart due to ping (or other authenticated packet)
  * not received in n seconds?
index fc3b527e6e7352f0c01dd835cd3bb05678af1c98..791d476bed3bdc7dc77b663225d95f79254109b3 100644 (file)
@@ -207,4 +207,6 @@ plugin_call(const struct plugin_list *pl,
     return plugin_call_ssl(pl, type, av, pr, es, -1, NULL);
 }
 
+void plugin_abort(void);
+
 #endif /* OPENVPN_PLUGIN_H */
index 7329a51858547135ce16cebcddc4944d9733563d..b445821ce82a265d565bff579c7a1f327fea1485 100644 (file)
@@ -994,11 +994,11 @@ link_socket_set_outgoing_addr(const struct buffer *buf,
     }
 }
 
+bool stream_buf_read_setup_dowork(struct link_socket *sock);
+
 static inline bool
 stream_buf_read_setup(struct link_socket *sock)
 {
-    bool stream_buf_read_setup_dowork(struct link_socket *sock);
-
     if (link_socket_connection_oriented(sock))
     {
         return stream_buf_read_setup_dowork(sock);
@@ -1103,16 +1103,17 @@ link_socket_write_win32(struct link_socket *sock,
 
 #else  /* ifdef _WIN32 */
 
+size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
+                                           struct buffer *buf,
+                                           struct link_socket_actual *to);
+
+
 static inline size_t
 link_socket_write_udp_posix(struct link_socket *sock,
                             struct buffer *buf,
                             struct link_socket_actual *to)
 {
 #if ENABLE_IP_PKTINFO
-    size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock,
-                                               struct buffer *buf,
-                                               struct link_socket_actual *to);
-
     if (proto_is_udp(sock->info.proto) && (sock->sockflags & SF_USE_IP_PKTINFO)
         && addr_defined_ipi(to))
     {