Skip to content

Commit ea2f8ef

Browse files
flichtenheldcron2
authored andcommitted
error: Allow status argument to check_status to be ssize_t
We only check for < 0 so no reason not to allow bigger signed values. This makes it easier to feed result values of read/write to it. Fixes a conversion warning in process_outgoing_tun. Also changes register_activity to int64_t for similar reasons. Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1357 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg34701.html Signed-off-by: Gert Doering <[email protected]>
1 parent 123cc9a commit ea2f8ef

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/openvpn/error.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,14 +621,14 @@ set_check_status(unsigned int info_level, unsigned int verbose_level)
621621
* from the OS.
622622
*/
623623
void
624-
x_check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
624+
x_check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
625625
{
626626
const char *extended_msg = NULL;
627627

628628
bool crt_error = false;
629629
int my_errno = openvpn_errno_maybe_crt(&crt_error);
630630

631-
msg(x_cs_verbose_level, "%s %s returned %d",
631+
msg(x_cs_verbose_level, "%s %s returned %zd",
632632
sock ? proto2ascii(sock->info.proto, sock->info.af, true) : "", description, status);
633633

634634
if (status < 0)

src/openvpn/error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ void reset_check_status(void);
307307

308308
void set_check_status(unsigned int info_level, unsigned int verbose_level);
309309

310-
void x_check_status(int status, const char *description, struct link_socket *sock,
310+
void x_check_status(ssize_t status, const char *description, struct link_socket *sock,
311311
struct tuntap *tt);
312312

313313
static inline void
314-
check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
314+
check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
315315
{
316316
if (status < 0 || check_debug_level(x_cs_verbose_level))
317317
{

src/openvpn/forward.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,10 @@ ipv6_send_icmp_unreachable(struct context *c, struct buffer *buf, bool client)
16731673
#undef MAX_ICMPV6LEN
16741674
}
16751675

1676+
#if defined(__GNUC__) || defined(__clang__)
1677+
#pragma GCC diagnostic pop
1678+
#endif
1679+
16761680
void
16771681
process_ip_header(struct context *c, unsigned int flags, struct buffer *buf,
16781682
struct link_socket *sock)
@@ -1915,7 +1919,7 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
19151919
/*
19161920
* Write to TUN/TAP device.
19171921
*/
1918-
int size;
1922+
ssize_t size;
19191923

19201924
#ifdef LOG_RW
19211925
if (c->c2.log_rw)
@@ -1956,7 +1960,7 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
19561960
if (size != BLEN(&c->c2.to_tun))
19571961
{
19581962
msg(D_LINK_ERRORS,
1959-
"TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%d)",
1963+
"TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%zd)",
19601964
c->c1.tuntap->actual_name, BLEN(&c->c2.to_tun), size);
19611965
}
19621966

@@ -1977,10 +1981,6 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
19771981
buf_reset(&c->c2.to_tun);
19781982
}
19791983

1980-
#if defined(__GNUC__) || defined(__clang__)
1981-
#pragma GCC diagnostic pop
1982-
#endif
1983-
19841984
void
19851985
pre_select(struct context *c)
19861986
{

src/openvpn/forward.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ get_link_socket_info(struct context *c)
343343
}
344344

345345
static inline void
346-
register_activity(struct context *c, const int size)
346+
register_activity(struct context *c, const int64_t size)
347347
{
348348
if (c->options.inactivity_timeout)
349349
{

0 commit comments

Comments
 (0)