[Openvpn-devel,v3] socket: make stream_buf_* functions static

Message ID 20180712012955.24050-1-a@unstable.cc
State Accepted
Headers show
Series [Openvpn-devel,v3] socket: make stream_buf_* functions static | expand

Commit Message

Antonio Quartulli July 11, 2018, 3:29 p.m. UTC
stream_buf_init(), stream_buf_close() and stream_buf_added()
are only used within socket.c, therefore there is noneed to
have them declared in socket.h.

Make them static and remove useless declarations.
This change reuired adding function prototypes in socket.c to
avoid useless code re-ordering.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
v2:
- fix commit subject
v3:
- move functions back to their original locations and add prototypes
  before the first usage of the three functions
---
 src/openvpn/socket.c | 22 +++++++++++++++++++---
 src/openvpn/socket.h | 15 ---------------
 2 files changed, 19 insertions(+), 18 deletions(-)

Comments

Gert Doering July 13, 2018, 12:19 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

"Having local code self-contained is good" - visually tested, and 
t_client test runs.  Thanks for bearing with me :)

Your patch has been applied to the master branch.

commit 62c0455e0fd48b4640251dc879c25d4f66ae3ed2
Author: Antonio Quartulli
Date:   Thu Jul 12 09:29:55 2018 +0800

     socket: make stream_buf_* functions static

     Signed-off-by: Antonio Quartulli <a@unstable.cc>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20180712012955.24050-1-a@unstable.cc>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17246.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Patch

diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 211e7441..29de56fd 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -1491,6 +1491,22 @@  done:
     gc_free(&gc);
 }
 
+/*
+ * Stream buffer handling prototypes -- stream_buf is a helper class
+ * to assist in the packetization of stream transport protocols
+ * such as TCP.
+ */
+
+static void
+stream_buf_init(struct stream_buf *sb, struct buffer *buf,
+                const unsigned int sockflags, const int proto);
+
+static void
+stream_buf_close(struct stream_buf *sb);
+
+static bool
+stream_buf_added(struct stream_buf *sb, int length_added);
+
 /* For stream protocols, allocate a buffer to build up packet.
  * Called after frame has been finalized. */
 
@@ -2500,7 +2516,7 @@  stream_buf_reset(struct stream_buf *sb)
     sb->len = -1;
 }
 
-void
+static void
 stream_buf_init(struct stream_buf *sb,
                 struct buffer *buf,
                 const unsigned int sockflags,
@@ -2574,7 +2590,7 @@  stream_buf_read_setup_dowork(struct link_socket *sock)
     return !sock->stream_buf.residual_fully_formed;
 }
 
-bool
+static bool
 stream_buf_added(struct stream_buf *sb,
                  int length_added)
 {
@@ -2641,7 +2657,7 @@  stream_buf_added(struct stream_buf *sb,
     }
 }
 
-void
+static void
 stream_buf_close(struct stream_buf *sb)
 {
     free_buf(&sb->residual);
diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h
index 479d1150..7329a518 100644
--- a/src/openvpn/socket.h
+++ b/src/openvpn/socket.h
@@ -994,21 +994,6 @@  link_socket_set_outgoing_addr(const struct buffer *buf,
     }
 }
 
-/*
- * Stream buffer handling -- stream_buf is a helper class
- * to assist in the packetization of stream transport protocols
- * such as TCP.
- */
-
-void stream_buf_init(struct stream_buf *sb,
-                     struct buffer *buf,
-                     const unsigned int sockflags,
-                     const int proto);
-
-void stream_buf_close(struct stream_buf *sb);
-
-bool stream_buf_added(struct stream_buf *sb, int length_added);
-
 static inline bool
 stream_buf_read_setup(struct link_socket *sock)
 {