Skip to content

Commit 1571d8f

Browse files
authored
HevTunnelMacOS: Fix signed/unsigned comparison in read/write result checks (#286)
Cast `sizeof(type)` to `ssize_t` when comparing against the return values of `read` and `write`, avoiding signed/unsigned mismatches and ensuring correct error handling on macOS.
1 parent da33382 commit 1571d8f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/hev-tunnel-macos.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ hev_tunnel_read (int fd, int mtu, HevTaskIOYielder yielder, void *yielder_data)
3030
iov[1].iov_len = buf->len;
3131

3232
s = hev_task_io_readv (fd, iov, 2, yielder, yielder_data);
33-
if (s <= sizeof (type)) {
33+
if (s <= (ssize_t)sizeof (type)) {
3434
pbuf_free (buf);
3535
return NULL;
3636
}
@@ -67,7 +67,7 @@ hev_tunnel_write (int fd, struct pbuf *buf)
6767
}
6868

6969
res = writev (fd, iov, i);
70-
if (res <= sizeof (type))
70+
if (res <= (ssize_t)sizeof (type))
7171
return -1;
7272

7373
return res;

0 commit comments

Comments
 (0)