/*
* This first step of the while is to clean this structure which could free
- * non NULL pointers so zero it before the loop.
+ * non NULL pointers so initialize it before the loop.
*/
- memset(&events, 0, sizeof(events));
+ lttng_poll_init(&events);
if (testpoint(thread_manage_kernel)) {
goto error_testpoint;
rcu_register_thread();
- /* We might hit an error path before this is set once. */
- memset(&events, 0, sizeof(events));
- events.epfd = -1;
+ /* We might hit an error path before this is created. */
+ lttng_poll_init(&events);
/* Create unix socket */
sock = lttcomm_create_unix_sock(health_unix_sock_path);
}
}
+/*
+ * Initialize an already allocated poll event data structure. For epoll(), the
+ * epfd is set to -1 to indicate that it's not usable.
+ */
+static inline void lttng_poll_init(struct lttng_poll_event *events)
+{
+ lttng_poll_reset(events);
+ /* Set fd to -1 so if clean before created, we don't close 0. */
+ events->epfd = -1;
+}
+
/*
* Clean the events structure of a lttng_poll_event. It's the caller
* responsability to free the lttng_poll_event memory.
static inline void lttng_poll_reset(struct lttng_poll_event *events)
{}
+/*
+ * Initialize an already allocated poll event data structure.
+ */
+static inline void lttng_poll_init(struct lttng_poll_event *events)
+{
+ memset(events, 0, sizeof(struct lttng_poll_event));
+}
+
/*
* Clean the events structure of a lttng_poll_event. It's the caller
* responsability to free the lttng_poll_event memory.