[PATCH v9] tun: Avoid sign-compare warning in header_modify_read_write_return

Gert Doering <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <[email protected]>
From: Frank Lichtenheld <[email protected]>

Since we already check that the value is positive
just make the implicit cast explicit.

Change-Id: I2ca40d0d86599896b38ea1467313b6a6cdc8339c
Signed-off-by: Frank Lichtenheld <[email protected]>
Acked-by: Razvan Cojocaru <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1527
---

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

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <[email protected]>

        
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index f46802f..28ec7b8 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -1706,17 +1706,12 @@
 #include <netinet/ip.h>
 #include <sys/uio.h>
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
 static inline ssize_t
 header_modify_read_write_return(ssize_t len)
 {
     if (len > 0)
     {
-        return len > sizeof(u_int32_t) ? len - sizeof(u_int32_t) : 0;
+        return (size_t)len > sizeof(u_int32_t) ? len - sizeof(u_int32_t) : 0;
     }
     else
     {
@@ -1724,10 +1719,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static ssize_t
 write_tun_header(struct tuntap *tt, uint8_t *buf, int len)
 {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.