Skip to content

Commit 7835c37

Browse files
flichtenheldcron2
authored andcommitted
forward: Change context_reschedule_sec sec argument to time_t
This avoids conversions at the caller sites. Since we only replace tv_sec if the new value is smaller the cast to tv_sec_t is also safe. Change-Id: Id9158f477404aac1d6b08b08e672980e5a58dc35 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Arne Schwabe <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1356 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg34319.html Signed-off-by: Gert Doering <[email protected]>
1 parent eb0666c commit 7835c37

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/openvpn/forward.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "mss.h"
3434
#include "event.h"
3535
#include "occ.h"
36+
#include "otime.h"
3637
#include "ping.h"
3738
#include "ps.h"
3839
#include "dhcp.h"
@@ -127,15 +128,15 @@ context_immediate_reschedule(struct context *c)
127128
}
128129

129130
static inline void
130-
context_reschedule_sec(struct context *c, int sec)
131+
context_reschedule_sec(struct context *c, time_t sec)
131132
{
132133
if (sec < 0)
133134
{
134135
sec = 0;
135136
}
136137
if (sec < c->c2.timeval.tv_sec)
137138
{
138-
c->c2.timeval.tv_sec = sec;
139+
c->c2.timeval.tv_sec = (tv_sec_t)sec;
139140
c->c2.timeval.tv_usec = 0;
140141
}
141142
}
@@ -829,11 +830,6 @@ process_coarse_timers(struct context *c)
829830
#endif /* ENABLE_MANAGEMENT */
830831
}
831832

832-
#if defined(__GNUC__) || defined(__clang__)
833-
#pragma GCC diagnostic push
834-
#pragma GCC diagnostic ignored "-Wconversion"
835-
#endif
836-
837833
static void
838834
check_coarse_timers(struct context *c)
839835
{
@@ -1304,6 +1300,11 @@ process_incoming_dco(struct context *c)
13041300
#endif /* if defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD)) */
13051301
}
13061302

1303+
#if defined(__GNUC__) || defined(__clang__)
1304+
#pragma GCC diagnostic push
1305+
#pragma GCC diagnostic ignored "-Wconversion"
1306+
#endif
1307+
13071308
/*
13081309
* Output: c->c2.buf
13091310
*/

0 commit comments

Comments
 (0)