Skip to contentSkip to conversation

Change in openvpn[master]: tun: Avoid sign-compare warning in header_modify_read_write_return

Openvpn-devel flichtenheld (Code Review) 1 participant 1 message Feb 13 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1771008896000.I2ca40d0d86599896b38ea1467313b6a6cdc8339c@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1527?usp=email

to review the following change.

Change subject: tun: Avoid sign-compare warning in header_modify_read_write_return
......................................................................

tun: Avoid sign-compare warning in header_modify_read_write_return

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

Change-Id I2ca40d0d86599896b38ea1467313b6a6cdc8339c

---
M src/openvpn/tun.c

1 file changed, 1 insertion(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/27/1527/1

src/openvpn/tun.c +1 -10
index a909e96..638611b 100644
@@ -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)
 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1527?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2ca40d0d86599896b38ea1467313b6a6cdc8339c
Gerrit-Change-Number: 1527
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>