]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
gremlin: Avoid some conversion warnings
authorFrank Lichtenheld <frank@lichtenheld.com>
Tue, 28 Oct 2025 18:39:35 +0000 (19:39 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 28 Oct 2025 18:54:11 +0000 (19:54 +0100)
We know these casts are safe, so make
them explicit.

Change-Id: I2554b9baec6af191b0adb137e64124586dc4331c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1286
Message-Id: <20251028183945.31901-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33964.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/gremlin.c

index 0e5e93fabdee2e88f325ee39a5dcdf686bfff208..a3dbff15896e854531145883e147ba6163516eff 100644 (file)
@@ -98,11 +98,6 @@ flip(int n)
     return (get_random() % n) == 0;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /*
  * Return uniformly distributed random number between
  * low and high.
@@ -112,7 +107,7 @@ roll(int low, int high)
 {
     int ret;
     ASSERT(low <= high);
-    ret = low + (get_random() % (high - low + 1));
+    ret = low + (int)(get_random() % (high - low + 1));
     ASSERT(ret >= low && ret <= high);
     return ret;
 }
@@ -195,7 +190,7 @@ corrupt_gremlin(struct buffer *buf, int flags)
             {
                 if (buf->len > 0)
                 {
-                    uint8_t r = roll(0, 255);
+                    uint8_t r = (uint8_t)roll(0, 255);
                     int method = roll(0, 5);
 
                     switch (method)
@@ -235,8 +230,4 @@ corrupt_gremlin(struct buffer *buf, int flags)
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* ifdef ENABLE_DEBUG */