]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Remove max_size from buffer_list_new
authorArne Schwabe <arne@rfc2549.org>
Tue, 7 Dec 2021 17:01:51 +0000 (18:01 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 7 Dec 2021 18:50:46 +0000 (19:50 +0100)
This argument is never used apart from a unit test. Remove this
argument as a small cleanup.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211207170211.3275837-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23329.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/buffer.c
src/openvpn/buffer.h
src/openvpn/manage.c
src/openvpn/ssl.c
tests/unit_tests/openvpn/test_buffer.c

index 486a7754885713cb8c8efff4bda8245757737483..37e9e7d0210aacc032465bcf47396bfb8a470329 100644 (file)
@@ -1171,11 +1171,10 @@ valign4(const struct buffer *buf, const char *file, const int line)
  * struct buffer_list
  */
 struct buffer_list *
-buffer_list_new(const int max_size)
+buffer_list_new(void)
 {
     struct buffer_list *ret;
     ALLOC_OBJ_CLEAR(ret, struct buffer_list);
-    ret->max_size = max_size;
     ret->size = 0;
     return ret;
 }
@@ -1229,7 +1228,7 @@ struct buffer_entry *
 buffer_list_push_data(struct buffer_list *ol, const void *data, size_t size)
 {
     struct buffer_entry *e = NULL;
-    if (data && (!ol->max_size || ol->size < ol->max_size))
+    if (data)
     {
         ALLOC_OBJ_CLEAR(e, struct buffer_entry);
 
@@ -1359,7 +1358,7 @@ buffer_list_file(const char *fn, int max_line_len)
         char *line = (char *) malloc(max_line_len);
         if (line)
         {
-            bl = buffer_list_new(0);
+            bl = buffer_list_new();
             while (fgets(line, max_line_len, fp) != NULL)
             {
                 buffer_list_push(bl, line);
index 8cc03c08f8384e5cf98332ca6f2b54238eefc5fe..8017130f6f2ca1fe8d0e16d24abb4bb6411e0617 100644 (file)
@@ -1102,11 +1102,9 @@ struct buffer_list
 /**
  * Allocate an empty buffer list of capacity \c max_size.
  *
- * @param max_size  the capacity of the list to allocate
- *
  * @return the new list
  */
-struct buffer_list *buffer_list_new(const int max_size);
+struct buffer_list *buffer_list_new(void);
 
 /**
  * Frees a buffer list and all the buffers in it.
index 28315b82adf84582ca22755d035c9b1d6a6615b8..1f408f0b59084cff278219af62c1fc53fe54c49b 100644 (file)
@@ -878,7 +878,7 @@ in_extra_reset(struct man_connection *mc, const int mode)
         }
         if (mode == IER_NEW)
         {
-            mc->in_extra = buffer_list_new(0);
+            mc->in_extra = buffer_list_new();
         }
     }
 }
@@ -2507,7 +2507,7 @@ man_connection_init(struct management *man)
          * command output from/to the socket.
          */
         man->connection.in = command_line_new(1024);
-        man->connection.out = buffer_list_new(0);
+        man->connection.out = buffer_list_new();
 
         /*
          * Initialize event set for standalone usage, when we are
index 3de229e39e218a10f9f4c18b7a3e10edb9bd614b..81b2a1afdbe1e4503ce917fb15320d752823055c 100644 (file)
@@ -3989,7 +3989,7 @@ tls_send_payload(struct tls_multi *multi,
     {
         if (!ks->paybuf)
         {
-            ks->paybuf = buffer_list_new(0);
+            ks->paybuf = buffer_list_new();
         }
         buffer_list_push_data(ks->paybuf, data, (size_t)size);
         ret = true;
index 5e854c22e509eed59419fa0f9760ff5d97b05626..ac701669f56c6137e159619b8e1babdb442926db 100644 (file)
@@ -67,18 +67,18 @@ static int
 test_buffer_list_setup(void **state)
 {
     struct test_buffer_list_aggregate_ctx *ctx  = calloc(1, sizeof(*ctx));
-    ctx->empty = buffer_list_new(0);
+    ctx->empty = buffer_list_new();
 
-    ctx->one_two_three = buffer_list_new(3);
+    ctx->one_two_three = buffer_list_new();
     buffer_list_push(ctx->one_two_three, teststr1);
     buffer_list_push(ctx->one_two_three, teststr2);
     buffer_list_push(ctx->one_two_three, teststr3);
 
-    ctx->zero_length_strings = buffer_list_new(2);
+    ctx->zero_length_strings = buffer_list_new();
     buffer_list_push(ctx->zero_length_strings, "");
     buffer_list_push(ctx->zero_length_strings, "");
 
-    ctx->empty_buffers = buffer_list_new(2);
+    ctx->empty_buffers = buffer_list_new();
     uint8_t data = 0;
     buffer_list_push_data(ctx->empty_buffers, &data, 0);
     buffer_list_push_data(ctx->empty_buffers, &data, 0);
@@ -100,17 +100,6 @@ test_buffer_list_teardown(void **state)
     return 0;
 }
 
-static void
-test_buffer_list_full(void **state)
-{
-    struct test_buffer_list_aggregate_ctx *ctx = *state;
-
-    /* list full */
-    assert_int_equal(ctx->one_two_three->size, 3);
-    buffer_list_push(ctx->one_two_three, teststr4);
-    assert_int_equal(ctx->one_two_three->size, 3);
-}
-
 static void
 test_buffer_list_aggregate_separator_empty(void **state)
 {
@@ -247,9 +236,6 @@ main(void)
 {
     const struct CMUnitTest tests[] = {
         cmocka_unit_test(test_buffer_strprefix),
-        cmocka_unit_test_setup_teardown(test_buffer_list_full,
-                                        test_buffer_list_setup,
-                                        test_buffer_list_teardown),
         cmocka_unit_test_setup_teardown(test_buffer_list_aggregate_separator_empty,
                                         test_buffer_list_setup,
                                         test_buffer_list_teardown),