From d02f1b4f417f71991b07fe89d397798f1183028d Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Fri, 14 May 2021 13:38:51 +0200 Subject: [PATCH] tun: Fix warning tun.c:389:19: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (addr.sc_unit < 0) { ~~~~~~~~~~~~ ^ ~ --- src/tun.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tun.c b/src/tun.c index a6b65b8..4c78895 100644 --- a/src/tun.c +++ b/src/tun.c @@ -360,6 +360,7 @@ open_utun(const char *dev) struct ctl_info info; char ifname[10]; socklen_t ifname_len = sizeof(ifname); + int unit; int fd = -1; int err = 0; @@ -385,11 +386,12 @@ open_utun(const char *dev) addr.sc_family = AF_SYSTEM; addr.ss_sysaddr = AF_SYS_CONTROL; addr.sc_id = info.ctl_id; - addr.sc_unit = utun_unit(dev); - if (addr.sc_unit < 0) { + unit = utun_unit(dev); + if (unit < 0) { close(fd); return -1; } + addr.sc_unit = unit; err = connect(fd, (struct sockaddr *)&addr, sizeof(addr)); if (err != 0) {