From 8ca960fa0274018cb4f94a1826029d74e6f762e0 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 21 Jun 2021 20:24:03 +0200 Subject: lib, ipcpd, irmd: Wrap pthread unlocks for cleanup This add an ouroboros/pthread.h header that wraps the pthread_..._unlock() functions for cleanup using pthread_cleanup_push() as this casting is not safe (and there were definitely bad casts in the code). The close() function is now also wrapped for cleanup in ouroboros/sockets.h. This allows enabling more compiler checks. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/eth/eth.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/ipcpd/eth/eth.c') diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c index 13a4a7e3..932034d5 100644 --- a/src/ipcpd/eth/eth.c +++ b/src/ipcpd/eth/eth.c @@ -48,13 +48,13 @@ #include #include #include +#include #include "ipcp.h" #include "shim-data.h" #include #include -#include #include #include #include @@ -807,8 +807,7 @@ static void * eth_ipcp_mgmt_handler(void * o) (void) o; - pthread_cleanup_push((void (*)(void *)) pthread_mutex_unlock, - (void *) ð_data.mgmt_lock); + pthread_cleanup_push(__cleanup_mutex_unlock, ð_data.mgmt_lock); while (true) { ret = 0; @@ -1162,12 +1161,6 @@ static void change_flows_state(bool up) pthread_rwlock_unlock(ð_data.flows_lock); } -static void close_ptr(void * o) -{ - close(*((int *) o)); -} - - static void * eth_ipcp_if_monitor(void * o) { int fd; @@ -1188,7 +1181,7 @@ static void * eth_ipcp_if_monitor(void * o) return (void *) -1; } - pthread_cleanup_push(close_ptr, &fd); + pthread_cleanup_push(__cleanup_close_ptr, &fd); while (true) { status = recvmsg(fd, &msg, 0); -- cgit v1.2.3