Skip to content

Commit 5e5ead5

Browse files
flichtenheldcron2
authored andcommitted
multi: Fix various conversion warnings
Mostly make required casts explicit. Change-Id: I88cd7e1ebb49e97db33bad75c4fbbe23d196e964 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Arne Schwabe <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1313 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg35073.html Signed-off-by: Gert Doering <[email protected]>
1 parent e2c97f3 commit 5e5ead5

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/openvpn/multi.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ cid_compare_function(const void *key1, const void *key2)
245245

246246
#endif
247247

248-
#if defined(__GNUC__) || defined(__clang__)
249-
#pragma GCC diagnostic push
250-
#pragma GCC diagnostic ignored "-Wconversion"
251-
#endif
252-
253248
#ifdef ENABLE_ASYNC_PUSH
254249
static uint32_t
255250
/*
@@ -2809,8 +2804,8 @@ void
28092804
multi_process_file_closed(struct multi_context *m, const unsigned int mpp_flags)
28102805
{
28112806
char buffer[INOTIFY_EVENT_BUFFER_SIZE];
2812-
size_t buffer_i = 0;
2813-
int r = read(m->top.c2.inotify_fd, buffer, INOTIFY_EVENT_BUFFER_SIZE);
2807+
ssize_t buffer_i = 0;
2808+
ssize_t r = read(m->top.c2.inotify_fd, buffer, INOTIFY_EVENT_BUFFER_SIZE);
28142809

28152810
while (buffer_i < r)
28162811
{
@@ -2942,21 +2937,23 @@ multi_bcast(struct multi_context *m, const struct buffer *buf,
29422937
static inline unsigned int
29432938
compute_wakeup_sigma(const struct timeval *delta)
29442939
{
2940+
ASSERT(delta->tv_sec >= 0);
2941+
ASSERT(delta->tv_usec >= 0);
29452942
if (delta->tv_sec < 1)
29462943
{
29472944
/* if < 1 sec, fuzz = # of microseconds / 8 */
2948-
return delta->tv_usec >> 3;
2945+
return (unsigned int)(delta->tv_usec >> 3);
29492946
}
29502947
else
29512948
{
29522949
/* if < 10 minutes, fuzz = 13.1% of timeout */
29532950
if (delta->tv_sec < 600)
29542951
{
2955-
return delta->tv_sec << 17;
2952+
return (unsigned int)(delta->tv_sec << 17);
29562953
}
29572954
else
29582955
{
2959-
return 120000000; /* if >= 10 minutes, fuzz = 2 minutes */
2956+
return 120 * 1000000; /* if >= 10 minutes, fuzz = 2 minutes */
29602957
}
29612958
}
29622959
}
@@ -3743,7 +3740,7 @@ gremlin_flood_clients(struct multi_context *m)
37433740

37443741
for (i = 0; i < parm.packet_size; ++i)
37453742
{
3746-
ASSERT(buf_write_u8(&buf, get_random() & 0xFF));
3743+
ASSERT(buf_write_u8(&buf, (uint8_t)(get_random() & 0xFF)));
37473744
}
37483745

37493746
for (i = 0; i < parm.n_packets; ++i)
@@ -3959,10 +3956,6 @@ management_callback_kill_by_addr(void *arg, const in_addr_t addr, const uint16_t
39593956
return count;
39603957
}
39613958

3962-
#if defined(__GNUC__) || defined(__clang__)
3963-
#pragma GCC diagnostic pop
3964-
#endif
3965-
39663959
static void
39673960
management_delete_event(void *arg, event_t event)
39683961
{

0 commit comments

Comments
 (0)