From: Donald Sharp Date: Fri, 3 Jun 2022 15:38:15 +0000 (-0400) Subject: lib, vrrpd: Use THREAD_ARG X-Git-Tag: base_8.4~208^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b8551584ee2b6cbdbcfabd04096c26923e336792;p=matthieu%2Ffrr.git lib, vrrpd: Use THREAD_ARG Don't auto set the thread->arg pointer. It is private and should be only accessed through the THREAD_ARG pointer. Signed-off-by: Donald Sharp --- diff --git a/lib/agentx.c b/lib/agentx.c index e03e19aad5..4c087219cb 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -146,9 +146,9 @@ static void agentx_events_update(void) else if (FD_ISSET(fd, &fds)) { struct listnode *newln; thr = XCALLOC(MTYPE_TMP, sizeof(struct thread *)); - thread_add_read(agentx_tm, agentx_read, NULL, fd, thr); + newln = listnode_add_before(events, ln, thr); - (*thr)->arg = newln; + thread_add_read(agentx_tm, agentx_read, newln, fd, thr); } } diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp index 9cb999110b..95721ffc77 100644 --- a/lib/northbound_grpc.cpp +++ b/lib/northbound_grpc.cpp @@ -198,7 +198,7 @@ class RpcStateBase static void c_callback(struct thread *thread) { - auto _tag = static_cast(thread->arg); + auto _tag = static_cast(THREAD_ARG(thread)); /* * We hold the lock until the callback finishes and has updated * _tag->state, then we signal done and release. diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c index 3081c0d955..4a0356411f 100644 --- a/vrrpd/vrrp.c +++ b/vrrpd/vrrp.c @@ -985,7 +985,7 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src, */ static void vrrp_read(struct thread *thread) { - struct vrrp_router *r = thread->arg; + struct vrrp_router *r = THREAD_ARG(thread); struct vrrp_pkt *pkt; ssize_t pktsize; @@ -1480,7 +1480,7 @@ static void vrrp_change_state(struct vrrp_router *r, int to) */ static void vrrp_adver_timer_expire(struct thread *thread) { - struct vrrp_router *r = thread->arg; + struct vrrp_router *r = THREAD_ARG(thread); DEBUGD(&vrrp_dbg_proto, VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM @@ -1508,7 +1508,7 @@ static void vrrp_adver_timer_expire(struct thread *thread) */ static void vrrp_master_down_timer_expire(struct thread *thread) { - struct vrrp_router *r = thread->arg; + struct vrrp_router *r = THREAD_ARG(thread); zlog_info(VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM "Master_Down_Timer expired",