tevent: use struct initializers for tevent_fd
authorStefan Metzmacher <metze@samba.org>
Thu, 23 Oct 2014 05:15:14 +0000 (07:15 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 17 May 2018 07:51:45 +0000 (09:51 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
lib/tevent/tevent_fd.c
lib/tevent/tevent_poll.c

index 455961b67c840db4dc90606b039030eb1ccf308d..f33ae841b3964324fb4a43319591f824f756a6c8 100644 (file)
@@ -60,16 +60,15 @@ struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev, TALLOC_CTX *me
        fde = talloc(mem_ctx?mem_ctx:ev, struct tevent_fd);
        if (!fde) return NULL;
 
-       fde->event_ctx          = ev;
-       fde->fd                 = fd;
-       fde->flags              = flags;
-       fde->handler            = handler;
-       fde->close_fn           = NULL;
-       fde->private_data       = private_data;
-       fde->handler_name       = handler_name;
-       fde->location           = location;
-       fde->additional_flags   = 0;
-       fde->additional_data    = NULL;
+       *fde = (struct tevent_fd) {
+               .event_ctx      = ev,
+               .fd             = fd,
+               .flags          = flags,
+               .handler        = handler,
+               .private_data   = private_data,
+               .handler_name   = handler_name,
+               .location       = location,
+       };
 
        DLIST_ADD(ev->fd_events, fde);
 
index 09d85fa322adff298eb6a1f5e7c72bccd6121881..f1d52533f5dee72079d43bc4e304ac276d1f7158 100644 (file)
@@ -307,16 +307,17 @@ static struct tevent_fd *poll_event_add_fd(struct tevent_context *ev,
        if (fde == NULL) {
                return NULL;
        }
-       fde->event_ctx          = ev;
-       fde->fd                 = fd;
-       fde->flags              = flags;
-       fde->handler            = handler;
-       fde->close_fn           = NULL;
-       fde->private_data       = private_data;
-       fde->handler_name       = handler_name;
-       fde->location           = location;
-       fde->additional_flags   = UINT64_MAX;
-       fde->additional_data    = NULL;
+
+       *fde = (struct tevent_fd) {
+               .event_ctx              = ev,
+               .fd                     = fd,
+               .flags                  = flags,
+               .handler                = handler,
+               .private_data           = private_data,
+               .handler_name           = handler_name,
+               .location               = location,
+               .additional_flags       = UINT64_MAX,
+       };
 
        tevent_poll_event_add_fd_internal(ev, fde);
        poll_event_wake_pollthread(poll_ev);