From: Ian Jackson Date: Sat, 27 Sep 2014 10:58:42 +0000 (+0100) Subject: fds: Simplify fd close condition in tun_set_route X-Git-Tag: base.ipv6-polypath-fixes-2.v1~123 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/secnet/commitdiff_plain/56fd04e41e9985260b8c1660e299cfe051d3f260?hp=4fb0f88d53fc60395a4a87b7a9ca1245ba033ee7 fds: Simplify fd close condition in tun_set_route Recreating the condition under which the fd was opened is confusing and fragile. Instead, simply close it if we opened it, which we can tell from the value of the variable (because we initialise it to -1 at the top). Signed-off-by: Ian Jackson --- diff --git a/tun.c b/tun.c index ffc195c..9ef3a9d 100644 --- a/tun.c +++ b/tun.c @@ -241,7 +241,7 @@ static bool_t tun_set_route(void *sst, struct netlink_client *routes) break; } } - if (st->route_type==TUN_CONFIG_IOCTL) { + if (fd >= 0) { close(fd); } routes->kup=up;