@@ -1300,11 +1300,6 @@
#endif /* if defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD)) */
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
/*
* Output: c->c2.buf
*/
@@ -1331,11 +1326,11 @@
if (c->c1.tuntap->backend_driver == DRIVER_AFUNIX)
{
c->c2.buf.len =
- read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size);
+ (int)read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size);
}
else
{
- c->c2.buf.len = read_tun(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size);
+ c->c2.buf.len = (int)read_tun(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size);
}
#endif /* ifdef _WIN32 */
@@ -1365,6 +1360,11 @@
check_status(c->c2.buf.len, "read from TUN/TAP", NULL, c->c1.tuntap);
}
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
/**
* Drops UDP packets which OS decided to route via tun.
*
@@ -1708,8 +1708,8 @@
#include <netinet/ip.h>
#include <sys/uio.h>
-static inline int
-header_modify_read_write_return(int len)
+static inline ssize_t
+header_modify_read_write_return(ssize_t len)
{
if (len > 0)
{
@@ -1721,12 +1721,7 @@
}
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
-static int
+static ssize_t
write_tun_header(struct tuntap *tt, uint8_t *buf, int len)
{
if (tt->type == DEV_TYPE_TUN)
@@ -1757,7 +1752,7 @@
}
}
-static int
+static ssize_t
read_tun_header(struct tuntap *tt, uint8_t *buf, int len)
{
if (tt->type == DEV_TYPE_TUN)
@@ -1778,26 +1773,21 @@
}
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
#if !defined(TARGET_DARWIN)
-int
+ssize_t
write_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return write_tun_header(tt, buf, len);
}
-int
+ssize_t
read_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return read_tun_header(tt, buf, len);
}
#endif
-
-#endif /* defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) || defined(TARGET_NETBSD) || if defined (TARGET_OPENBSD) || defined(TARGET_DARWIN) */
+#endif /* if defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) || defined(TARGET_NETBSD) || defined (TARGET_OPENBSD) || defined(TARGET_DARWIN) */
bool
tun_name_is_fixed(const char *dev)
@@ -2054,13 +2044,13 @@
free(tt);
}
-int
+ssize_t
write_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return write(tt->fd, buf, len);
}
-int
+ssize_t
read_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return read(tt->fd, buf, len);
@@ -2268,27 +2258,18 @@
free(tt);
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
-int
+ssize_t
write_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return write(tt->fd, buf, len);
}
-int
+ssize_t
read_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return read(tt->fd, buf, len);
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
#elif defined(TARGET_SOLARIS)
#ifndef TUNNEWPPA
@@ -2613,7 +2594,7 @@
argv_free(&argv);
}
-int
+ssize_t
write_tun(struct tuntap *tt, uint8_t *buf, int len)
{
struct strbuf sbuf;
@@ -2622,7 +2603,7 @@
return putmsg(tt->fd, NULL, &sbuf, 0) >= 0 ? sbuf.len : -1;
}
-int
+ssize_t
read_tun(struct tuntap *tt, uint8_t *buf, int len)
{
struct strbuf sbuf;
@@ -3097,11 +3078,6 @@
}
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
void
close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx)
{
@@ -3125,7 +3101,7 @@
gc_free(&gc);
}
-int
+ssize_t
write_tun(struct tuntap *tt, uint8_t *buf, int len)
{
if (tt->backend_driver == DRIVER_UTUN)
@@ -3138,7 +3114,7 @@
}
}
-int
+ssize_t
read_tun(struct tuntap *tt, uint8_t *buf, int len)
{
if (tt->backend_driver == DRIVER_UTUN)
@@ -3151,10 +3127,6 @@
}
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
#elif defined(TARGET_AIX)
void
@@ -3277,13 +3249,13 @@
argv_free(&argv);
}
-int
+ssize_t
write_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return write(tt->fd, buf, len);
}
-int
+ssize_t
read_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return read(tt->fd, buf, len);
@@ -6329,13 +6301,13 @@
free(tt);
}
-int
+ssize_t
write_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return write(tt->fd, buf, len);
}
-int
+ssize_t
read_tun(struct tuntap *tt, uint8_t *buf, int len)
{
return read(tt->fd, buf, len);
@@ -274,9 +274,9 @@
void close_tun_handle(struct tuntap *tt);
-int write_tun(struct tuntap *tt, uint8_t *buf, int len);
+ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len);
-int read_tun(struct tuntap *tt, uint8_t *buf, int len);
+ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len);
void tuncfg(const char *dev, const char *dev_type, const char *dev_node, int persist_mode,
const char *username, const char *groupname, const struct tuntap_options *options,