summaryrefslogtreecommitdiff
path: root/src/ipcpd/eth
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2021-06-21 20:24:03 +0200
committerSander Vrijders <sander@ouroboros.rocks>2021-06-23 08:36:48 +0200
commit8ca960fa0274018cb4f94a1826029d74e6f762e0 (patch)
tree268ffb6b24027d65c738a8edd196a1ed52134fcc /src/ipcpd/eth
parentac53f8ea09b9a24321bc2c00832ba8a117115134 (diff)
downloadouroboros-8ca960fa0274018cb4f94a1826029d74e6f762e0.tar.gz
ouroboros-8ca960fa0274018cb4f94a1826029d74e6f762e0.zip
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 <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/eth')
-rw-r--r--src/ipcpd/eth/eth.c13
1 files changed, 3 insertions, 10 deletions
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 <ouroboros/logs.h>
#include <ouroboros/time_utils.h>
#include <ouroboros/fccntl.h>
+#include <ouroboros/pthread.h>
#include "ipcp.h"
#include "shim-data.h"
#include <signal.h>
#include <stdlib.h>
-#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
@@ -807,8 +807,7 @@ static void * eth_ipcp_mgmt_handler(void * o)
(void) o;
- pthread_cleanup_push((void (*)(void *)) pthread_mutex_unlock,
- (void *) &eth_data.mgmt_lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &eth_data.mgmt_lock);
while (true) {
ret = 0;
@@ -1162,12 +1161,6 @@ static void change_flows_state(bool up)
pthread_rwlock_unlock(&eth_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);