[Openvpn-devel,v1] comp-lz4: Fix types in call to LZ4_decompress_safe

Message ID 20250926164845.1215-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] comp-lz4: Fix types in call to LZ4_decompress_safe | expand

Commit Message

Gert Doering Sept. 26, 2025, 4:48 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

This is ints all around but we uselessly threw some
size_t conversions in there.

Change-Id: Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: MaxF <max@max-fillinger.net>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
MaxF <max@max-fillinger.net>

Comments

Gert Doering Sept. 26, 2025, 5:05 p.m. UTC | #1
Ints all around... and one set of #pragma gone again :-) - BB t_client
tests do test lz4, so the code is excercised.

Your patch has been applied to the master branch.

commit 2682fb541ef9068e9707a3a90c16038e6f516b0f
Author: Frank Lichtenheld
Date:   Fri Sep 26 18:48:39 2025 +0200

     comp-lz4: Fix types in call to LZ4_decompress_safe

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: MaxF <max@max-fillinger.net>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
     Message-Id: <20250926164845.1215-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33228.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/comp-lz4.c b/src/openvpn/comp-lz4.c
index a78c664..53a5b3f 100644
--- a/src/openvpn/comp-lz4.c
+++ b/src/openvpn/comp-lz4.c
@@ -88,19 +88,13 @@ 
     compv2_escape_data_ifneeded(buf);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static void
-do_lz4_decompress(size_t zlen_max, struct buffer *work, struct buffer *buf,
+do_lz4_decompress(int zlen_max, struct buffer *work, struct buffer *buf,
                   struct compress_context *compctx)
 {
-    int uncomp_len;
     ASSERT(buf_safe(work, zlen_max));
-    uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), (size_t)BLEN(buf),
-                                     zlen_max);
+    int uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), BLEN(buf),
+                                         zlen_max);
     if (uncomp_len <= 0)
     {
         dmsg(D_COMP_ERRORS, "LZ4 decompression error: %d", uncomp_len);
@@ -118,15 +112,11 @@ 
     *buf = *work;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static void
 lz4_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)
@@ -163,7 +153,7 @@ 
 lz4v2_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                  const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)