[Openvpn-devel,v1] schedule: Fix conversion warning

Message ID 20251013162313.2276-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] schedule: Fix conversion warning | expand

Commit Message

Gert Doering Oct. 13, 2025, 4:23 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

Return value of random() is safe to cast.

Change-Id: I5e6cb3a287a2e8e1584036307b4c21bb68050c6a
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1270
---

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/+/1270
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering Oct. 13, 2025, 4:28 p.m. UTC | #1
Trivial enough... and should we really end up loosing a few bits, it
just does not matter at this point.

Your patch has been applied to the master branch.

commit f79221a9e0ee0ce4100b02ac5070f9d18fc7e8a8
Author: Frank Lichtenheld
Date:   Mon Oct 13 18:23:08 2025 +0200

     schedule: Fix conversion warning

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1270
     Message-Id: <20251013162313.2276-1-gert@greenie.muc.de>
     URL: https://sourceforge.net/p/openvpn/mailman/message/59246224/
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/schedule.c b/src/openvpn/schedule.c
index 1389889..bf6693f 100644
--- a/src/openvpn/schedule.c
+++ b/src/openvpn/schedule.c
@@ -65,25 +65,16 @@ 
 }
 #endif
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static inline void
 schedule_set_pri(struct schedule_entry *e)
 {
-    e->pri = random();
+    e->pri = (unsigned int)random();
     if (e->pri < 1)
     {
         e->pri = 1;
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /* This is the master key comparison routine.  A key is
  * simply a struct timeval containing the absolute time for
  * an event.  The unique treap priority (pri) is used to ensure