From a483bc8597e5c19e796dc55c0587f1a045bc7281 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Wed, 11 Oct 2017 15:28:43 +0200 Subject: ipcpd: Fix unreachable code in shim-eth-llc Closing the file descriptor after a while(true) loop led to clang compiler errors. This is fixed by adding a cleanup handler. --- src/ipcpd/shim-eth-llc/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index ca0c8166..52b111a5 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -821,6 +821,12 @@ static void change_flows_state(bool up) pthread_rwlock_unlock(ð_llc_data.flows_lock); } +static void close_ptr(void * o) +{ + close(*((int *) o)); +} + + static void * eth_llc_ipcp_if_monitor(void * o) { int fd; @@ -841,6 +847,8 @@ static void * eth_llc_ipcp_if_monitor(void * o) return (void *) -1; } + pthread_cleanup_push(close_ptr, &fd); + while (true) { status = recvmsg(fd, &msg, 0); if (status < 0) @@ -878,7 +886,7 @@ static void * eth_llc_ipcp_if_monitor(void * o) } } - close(fd); + pthread_cleanup_pop(true); return (void *) 0; } -- cgit v1.2.3