summaryrefslogtreecommitdiffstats
path: root/ldpd/ldpe.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2017-05-05 23:22:25 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2017-05-09 22:44:22 +0200
commit66e78ae64bc4659848517953b365606e3e70e878 (patch)
treeef1339e397feed2b56b8d653d41c03aa5b2bd94f /ldpd/ldpe.c
parentlib: safely check & set thread pointers (diff)
downloadfrr-66e78ae64bc4659848517953b365606e3e70e878.tar.xz
frr-66e78ae64bc4659848517953b365606e3e70e878.zip
*: update thread_add_* calls
Pass pointer to pointer instead of assigning by return value. See previous commit message. To ensure that the behavior stays functionally correct, any assignments with the result of a thread_add* function have been transformed to set the pointer to null before passing it. These can be removed wherever the pointer is known to already be null. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'ldpd/ldpe.c')
-rw-r--r--ldpd/ldpe.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c
index 9f87e58c4..ce2441ca2 100644
--- a/ldpd/ldpe.c
+++ b/ldpd/ldpe.c
@@ -119,8 +119,9 @@ ldpe(void)
fatal(NULL);
imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC);
iev_main->handler_read = ldpe_dispatch_main;
- iev_main->ev_read = thread_add_read(master, iev_main->handler_read,
- iev_main, iev_main->ibuf.fd, NULL);
+ iev_main->ev_read = NULL;
+ thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd,
+ &iev_main->ev_read);
iev_main->handler_write = ldp_write_handler;
if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL)
@@ -164,9 +165,11 @@ ldpe_init(struct ldpd_init *init)
fatal("inet_pton");
#ifdef __OpenBSD__
global.pfkeysock = pfkey_init();
- if (sysdep.no_pfkey == 0)
- pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey, NULL,
- global.pfkeysock, NULL);
+ if (sysdep.no_pfkey == 0) {
+ pfkey_ev = NULL;
+ thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
+ &pfkey_ev);
+ }
#endif
/* mark sockets as closed */
@@ -353,11 +356,9 @@ ldpe_dispatch_main(struct thread *thread)
fatal(NULL);
imsg_init(&iev_lde->ibuf, fd);
iev_lde->handler_read = ldpe_dispatch_lde;
- iev_lde->ev_read = thread_add_read(master,
- iev_lde->handler_read,
- iev_lde,
- iev_lde->ibuf.fd,
- NULL);
+ iev_lde->ev_read = NULL;
+ thread_add_read(master, iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd,
+ &iev_lde->ev_read);
iev_lde->handler_write = ldp_write_handler;
iev_lde->ev_write = NULL;
break;
@@ -697,8 +698,9 @@ ldpe_dispatch_pfkey(struct thread *thread)
{
int fd = THREAD_FD(thread);
- pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey, NULL,
- global.pfkeysock, NULL);
+ pfkey_ev = NULL;
+ thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
+ &pfkey_ev);
if (pfkey_read(fd, NULL) == -1)
fatal("pfkey_read failed, exiting...");
@@ -717,16 +719,15 @@ ldpe_setup_sockets(int af, int disc_socket, int edisc_socket,
/* discovery socket */
af_global->ldp_disc_socket = disc_socket;
- af_global->disc_ev = thread_add_read(master, disc_recv_packet,
- &af_global->disc_ev,
- af_global->ldp_disc_socket, NULL);
+ af_global->disc_ev = NULL;
+ thread_add_read(master, disc_recv_packet, &af_global->disc_ev, af_global->ldp_disc_socket,
+ &af_global->disc_ev);
/* extended discovery socket */
af_global->ldp_edisc_socket = edisc_socket;
- af_global->edisc_ev = thread_add_read(master, disc_recv_packet,
- &af_global->edisc_ev,
- af_global->ldp_edisc_socket,
- NULL);
+ af_global->edisc_ev = NULL;
+ thread_add_read(master, disc_recv_packet, &af_global->edisc_ev, af_global->ldp_edisc_socket,
+ &af_global->edisc_ev);
/* session socket */
af_global->ldp_session_socket = session_socket;