Add safety assert() in session daemon
authorDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 16:38:11 +0000 (11:38 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 17:42:21 +0000 (12:42 -0500)
Note here that a test has been removed which tested the NULL parameter
of the session_destroy() call where now we assert if there is a NULL
pointer. It's a code flow error if a NULL pointer gets to this call so
the test becomes irrelevant.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/context.c
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/shm.c
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng-sessiond/trace-ust.c
tests/tools/test_sessions.c

index 559c3d154034193381357540e0c0bc7a01f30ce0..e11d6d11fbcffa74d813d0722dcc7a4e65bc10aa 100644 (file)
@@ -90,11 +90,17 @@ int channel_kernel_disable(struct ltt_kernel_session *ksession,
        int ret;
        struct ltt_kernel_channel *kchan;
 
+       assert(ksession);
+       assert(channel_name);
+
        kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
        if (kchan == NULL) {
                ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
                goto error;
-       } else if (kchan->enabled == 1) {
+       }
+
+       /* Only if channel is enabled disable it. */
+       if (kchan->enabled == 1) {
                ret = kernel_disable_channel(kchan);
                if (ret < 0 && ret != -EEXIST) {
                        ret = LTTNG_ERR_KERN_CHAN_DISABLE_FAIL;
@@ -116,6 +122,9 @@ int channel_kernel_enable(struct ltt_kernel_session *ksession,
 {
        int ret;
 
+       assert(ksession);
+       assert(kchan);
+
        if (kchan->enabled == 0) {
                ret = kernel_enable_channel(kchan);
                if (ret < 0) {
@@ -142,6 +151,8 @@ int channel_kernel_create(struct ltt_kernel_session *ksession,
        int ret;
        struct lttng_channel *defattr = NULL;
 
+       assert(ksession);
+
        /* Creating channel attributes if needed */
        if (attr == NULL) {
                defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL);
@@ -180,6 +191,9 @@ int channel_ust_enable(struct ltt_ust_session *usess, int domain,
 {
        int ret = LTTNG_OK;
 
+       assert(usess);
+       assert(uchan);
+
        /* If already enabled, everything is OK */
        if (uchan->enabled) {
                DBG3("Channel %s already enabled. Skipping", uchan->name);
@@ -229,6 +243,8 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
        struct ltt_ust_channel *uchan = NULL;
        struct lttng_channel *defattr = NULL;
 
+       assert(usess);
+
        /* Creating channel attributes if needed */
        if (attr == NULL) {
                defattr = channel_new_default_attr(domain);
@@ -245,16 +261,18 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
        }
 
        /*
-        * Validate UST buffer size and number of buffers: must both be
-        * power of 2 and nonzero. We validate right here for UST,
-        * because applications will not report the error to the user
-        * (unlike kernel tracing).
+        * Validate UST buffer size and number of buffers: must both be power of 2
+        * and nonzero. We validate right here for UST, because applications will
+        * not report the error to the user (unlike kernel tracing).
         */
-       if (!attr->attr.subbuf_size || (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
+       if (!attr->attr.subbuf_size ||
+                       (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
                ret = LTTNG_ERR_INVALID;
                goto error;
        }
-       if (!attr->attr.num_subbuf || (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
+
+       if (!attr->attr.num_subbuf ||
+                       (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
                ret = LTTNG_ERR_INVALID;
                goto error;
        }
@@ -323,6 +341,9 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain,
 {
        int ret = LTTNG_OK;
 
+       assert(usess);
+       assert(uchan);
+
        /* Already disabled */
        if (uchan->enabled == 0) {
                DBG2("Channel UST %s already disabled", uchan->name);
index cee61f764ce192350583154df8e40d808ef7edac..c1b7410da00020dc541313326892d850e6810b28 100644 (file)
@@ -39,6 +39,9 @@ static int add_kctx_all_channels(struct ltt_kernel_session *ksession,
        int ret;
        struct ltt_kernel_channel *kchan;
 
+       assert(ksession);
+       assert(kctx);
+
        DBG("Adding kernel context to all channels");
 
        /* Go over all channels */
@@ -64,6 +67,9 @@ static int add_kctx_to_channel(struct lttng_kernel_context *kctx,
 {
        int ret;
 
+       assert(kchan);
+       assert(kctx);
+
        DBG("Add kernel context to channel '%s'", kchan->channel->name);
 
        ret = kernel_add_channel_context(kchan, kctx);
@@ -89,6 +95,10 @@ static int add_uctx_to_channel(struct ltt_ust_session *usess, int domain,
        struct lttng_ht_iter iter;
        struct lttng_ht_node_ulong *uctx_node;
 
+       assert(usess);
+       assert(uchan);
+       assert(ctx);
+
        /* Create ltt UST context */
        uctx = trace_ust_create_context(ctx);
        if (uctx == NULL) {
@@ -142,6 +152,10 @@ int context_kernel_add(struct ltt_kernel_session *ksession,
        struct ltt_kernel_channel *kchan;
        struct lttng_kernel_context kctx;
 
+       assert(ksession);
+       assert(ctx);
+       assert(channel_name);
+
        /* Setup kernel context structure */
        switch (ctx->ctx) {
        case LTTNG_EVENT_CONTEXT_PID:
@@ -223,6 +237,10 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        struct lttng_ht *chan_ht;
        struct ltt_ust_channel *uchan = NULL;
 
+       assert(usess);
+       assert(ctx);
+       assert(channel_name);
+
        /*
         * Define which channel's hashtable to use from the domain or quit if
         * unknown domain.
index 0fec563ad63c41c9db8e063fe98b87dbcde5b129..573e5a15657594c7e0d3a51f11087a1445787803 100644 (file)
@@ -60,6 +60,8 @@ static void add_unique_ust_event(struct lttng_ht *ht,
  */
 static void init_syscalls_kernel_event(struct lttng_event *event)
 {
+       assert(event);
+
        event->name[0] = '\0';
        /*
         * We use LTTNG_EVENT* here since the trace kernel creation will make the
@@ -77,6 +79,8 @@ int event_kernel_disable_tracepoint(struct ltt_kernel_session *ksession,
        int ret;
        struct ltt_kernel_event *kevent;
 
+       assert(kchan);
+
        kevent = trace_kernel_get_event_by_name(event_name, kchan);
        if (kevent == NULL) {
                ret = LTTNG_ERR_NO_EVENT;
@@ -107,6 +111,8 @@ int event_kernel_disable_all_tracepoints(struct ltt_kernel_session *ksession,
        int ret;
        struct ltt_kernel_event *kevent;
 
+       assert(kchan);
+
        /* For each event in the kernel session */
        cds_list_for_each_entry(kevent, &kchan->events_list.head, list) {
                ret = kernel_disable_event(kevent);
@@ -137,6 +143,9 @@ int event_kernel_disable_all(struct ltt_kernel_session *ksession,
 {
        int ret;
 
+       assert(ksession);
+       assert(kchan);
+
        ret = event_kernel_disable_all_tracepoints(ksession, kchan);
        if (ret != LTTNG_OK)
                return ret;
@@ -153,6 +162,9 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession,
        int ret;
        struct ltt_kernel_event *kevent;
 
+       assert(kchan);
+       assert(event);
+
        kevent = trace_kernel_get_event_by_name(event->name, kchan);
        if (kevent == NULL) {
                ret = kernel_create_event(event, kchan);
@@ -197,6 +209,8 @@ int event_kernel_enable_all_tracepoints(struct ltt_kernel_session *ksession,
        struct ltt_kernel_event *kevent;
        struct lttng_event *event_list = NULL;
 
+       assert(kchan);
+
        /* For each event in the kernel session */
        cds_list_for_each_entry(kevent, &kchan->events_list.head, list) {
                if (kevent->enabled == 0) {
@@ -231,7 +245,6 @@ int event_kernel_enable_all_tracepoints(struct ltt_kernel_session *ksession,
        ret = LTTNG_OK;
 end:
        return ret;
-
 }
 
 /*
@@ -243,6 +256,8 @@ int event_kernel_enable_all_syscalls(struct ltt_kernel_session *ksession,
        int ret;
        struct lttng_event event;
 
+       assert(kchan);
+
        init_syscalls_kernel_event(&event);
 
        DBG("Enabling all syscall tracing");
@@ -270,7 +285,11 @@ int event_kernel_enable_all(struct ltt_kernel_session *ksession,
 {
        int tp_ret;
 
-       tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
+       assert(ksession);
+       assert(kchan);
+
+       tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan,
+                       kernel_tracer_fd);
        if (tp_ret != LTTNG_OK) {
                goto end;
        }
@@ -307,6 +326,9 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
        struct ltt_ust_event *uevent = NULL;
        struct lttng_event *events = NULL;
 
+       assert(usess);
+       assert(uchan);
+
        rcu_read_lock();
 
        switch (domain) {
@@ -412,6 +434,10 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain,
        int ret = LTTNG_OK, to_create = 0;
        struct ltt_ust_event *uevent;
 
+       assert(usess);
+       assert(uchan);
+       assert(event);
+
        rcu_read_lock();
 
        uevent = trace_ust_find_event(uchan->events, event->name, filter,
@@ -509,6 +535,10 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, int domain,
        struct lttng_ht_iter iter;
        struct lttng_ht *ht;
 
+       assert(usess);
+       assert(uchan);
+       assert(event_name);
+
        ht = uchan->events;
 
        rcu_read_lock();
@@ -583,6 +613,9 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
        struct ltt_ust_event *uevent = NULL;
        struct lttng_event *events = NULL;
 
+       assert(usess);
+       assert(uchan);
+
        rcu_read_lock();
 
        switch (domain) {
index b417cb07759c4f30795b9240508b31e2148ffd77..32c40531d21b3e50f4d7b1851594b2ad1090ea4f 100644 (file)
@@ -40,6 +40,9 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan,
 {
        int ret;
 
+       assert(chan);
+       assert(ctx);
+
        DBG("Adding context to channel %s", chan->channel->name);
        ret = kernctl_add_context(chan->fd, ctx);
        if (ret < 0) {
@@ -75,6 +78,8 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd)
        int ret;
        struct ltt_kernel_session *lks;
 
+       assert(session);
+
        /* Allocate data structure */
        lks = trace_kernel_create_session(session->path);
        if (lks == NULL) {
@@ -118,6 +123,10 @@ int kernel_create_channel(struct ltt_kernel_session *session,
        int ret;
        struct ltt_kernel_channel *lkc;
 
+       assert(session);
+       assert(chan);
+       assert(path);
+
        /* Allocate kernel channel */
        lkc = trace_kernel_create_channel(chan, path);
        if (lkc == NULL) {
@@ -168,6 +177,9 @@ int kernel_create_event(struct lttng_event *ev,
        int ret;
        struct ltt_kernel_event *event;
 
+       assert(ev);
+       assert(channel);
+
        event = trace_kernel_create_event(ev);
        if (event == NULL) {
                ret = -1;
@@ -231,6 +243,8 @@ int kernel_disable_channel(struct ltt_kernel_channel *chan)
 {
        int ret;
 
+       assert(chan);
+
        ret = kernctl_disable(chan->fd);
        if (ret < 0) {
                PERROR("disable chan ioctl");
@@ -254,6 +268,8 @@ int kernel_enable_channel(struct ltt_kernel_channel *chan)
 {
        int ret;
 
+       assert(chan);
+
        ret = kernctl_enable(chan->fd);
        if (ret < 0 && errno != EEXIST) {
                PERROR("Enable kernel chan");
@@ -276,6 +292,8 @@ int kernel_enable_event(struct ltt_kernel_event *event)
 {
        int ret;
 
+       assert(event);
+
        ret = kernctl_enable(event->fd);
        if (ret < 0) {
                switch (errno) {
@@ -305,6 +323,8 @@ int kernel_disable_event(struct ltt_kernel_event *event)
 {
        int ret;
 
+       assert(event);
+
        ret = kernctl_disable(event->fd);
        if (ret < 0) {
                switch (errno) {
@@ -336,6 +356,8 @@ int kernel_open_metadata(struct ltt_kernel_session *session)
        int ret;
        struct ltt_kernel_metadata *lkm;
 
+       assert(session);
+
        /* Allocate kernel metadata */
        lkm = trace_kernel_create_metadata();
        if (lkm == NULL) {
@@ -372,6 +394,8 @@ int kernel_start_session(struct ltt_kernel_session *session)
 {
        int ret;
 
+       assert(session);
+
        ret = kernctl_start_session(session->fd);
        if (ret < 0) {
                PERROR("ioctl start session");
@@ -409,6 +433,8 @@ int kernel_calibrate(int fd, struct lttng_kernel_calibrate *calibrate)
 {
        int ret;
 
+       assert(calibrate);
+
        ret = kernctl_calibrate(fd, calibrate);
        if (ret < 0) {
                PERROR("calibrate ioctl");
@@ -442,6 +468,8 @@ int kernel_flush_buffer(struct ltt_kernel_channel *channel)
        int ret;
        struct ltt_kernel_stream *stream;
 
+       assert(channel);
+
        DBG("Flush buffer for channel %s", channel->channel->name);
 
        cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
@@ -464,6 +492,8 @@ int kernel_stop_session(struct ltt_kernel_session *session)
 {
        int ret;
 
+       assert(session);
+
        ret = kernctl_stop_session(session->fd);
        if (ret < 0) {
                goto error;
@@ -488,6 +518,8 @@ int kernel_open_channel_stream(struct ltt_kernel_channel *channel)
        int ret, count = 0;
        struct ltt_kernel_stream *lks;
 
+       assert(channel);
+
        while ((ret = kernctl_create_stream(channel->fd)) >= 0) {
                lks = trace_kernel_create_stream(channel->channel->name, count);
                if (lks == NULL) {
@@ -529,6 +561,8 @@ int kernel_open_metadata_stream(struct ltt_kernel_session *session)
 {
        int ret;
 
+       assert(session);
+
        ret = kernctl_create_stream(session->metadata->fd);
        if (ret < 0) {
                PERROR("kernel create metadata stream");
@@ -560,6 +594,8 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
        FILE *fp;
        struct lttng_event *elist;
 
+       assert(events);
+
        fd = kernctl_tracepoint_list(tracer_fd);
        if (fd < 0) {
                PERROR("kernel tracepoint list");
index 7d0ee7d4abb82656d1f9493a58304d5e007bb7f5..65e3145a5fd63bae374117a25e25261300eaec91 100644 (file)
@@ -56,6 +56,8 @@ static struct ltt_session_list ltt_session_list = {
  */
 static unsigned int add_session_list(struct ltt_session *ls)
 {
+       assert(ls);
+
        cds_list_add(&ls->list, &ltt_session_list.head);
        return ltt_session_list.next_uuid++;
 }
@@ -67,6 +69,8 @@ static unsigned int add_session_list(struct ltt_session *ls)
  */
 static void del_session_list(struct ltt_session *ls)
 {
+       assert(ls);
+
        cds_list_del(&ls->list);
 }
 
@@ -99,6 +103,8 @@ void session_unlock_list(void)
  */
 void session_lock(struct ltt_session *session)
 {
+       assert(session);
+
        pthread_mutex_lock(&session->lock);
 }
 
@@ -107,6 +113,8 @@ void session_lock(struct ltt_session *session)
  */
 void session_unlock(struct ltt_session *session)
 {
+       assert(session);
+
        pthread_mutex_unlock(&session->lock);
 }
 
@@ -119,6 +127,8 @@ struct ltt_session *session_find_by_name(char *name)
 {
        struct ltt_session *iter;
 
+       assert(name);
+
        DBG2("Trying to find session by name %s", name);
 
        cds_list_for_each_entry(iter, &ltt_session_list.head, list) {
@@ -141,10 +151,7 @@ found:
 int session_destroy(struct ltt_session *session)
 {
        /* Safety check */
-       if (session == NULL) {
-               ERR("Session pointer was null on session destroy");
-               return LTTNG_OK;
-       }
+       assert(session);
 
        DBG("Destroying session %s", session->name);
        del_session_list(session);
index 584ae078f2d84fe07c32f4c8752850612908fc41..b94f4eb6a7aae86aed5fc080689e3f755456c719 100644 (file)
@@ -43,6 +43,8 @@ static int get_wait_shm(char *shm_path, size_t mmap_size, int global)
        int wait_shm_fd, ret;
        mode_t mode;
 
+       assert(shm_path);
+
        /* Default permissions */
        mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
 
@@ -138,6 +140,8 @@ char *shm_ust_get_mmap(char *shm_path, int global)
        int wait_shm_fd, ret;
        char *wait_shm_mmap;
 
+       assert(shm_path);
+
        wait_shm_fd = get_wait_shm(shm_path, mmap_size, global);
        if (wait_shm_fd < 0) {
                goto error;
index f38cf3d8d0a6f96a48250cafd58b96a8f53feb36..12189b9ea7929695576f27a33a13b46fa9a6b3dd 100644 (file)
@@ -35,10 +35,8 @@ struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
 {
        struct ltt_kernel_channel *chan;
 
-       if (session == NULL) {
-               ERR("Undefine session");
-               goto error;
-       }
+       assert(session);
+       assert(name);
 
        DBG("Trying to find channel %s", name);
 
@@ -49,7 +47,6 @@ struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
                }
        }
 
-error:
        return NULL;
 }
 
@@ -61,10 +58,8 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(
 {
        struct ltt_kernel_event *ev;
 
-       if (channel == NULL) {
-               ERR("Undefine channel");
-               goto error;
-       }
+       assert(name);
+       assert(channel);
 
        cds_list_for_each_entry(ev, &channel->events_list.head, list) {
                if (strcmp(name, ev->event->name) == 0) {
@@ -74,7 +69,6 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(
                }
        }
 
-error:
        return NULL;
 }
 
@@ -153,6 +147,8 @@ struct ltt_kernel_channel *trace_kernel_create_channel(
 {
        struct ltt_kernel_channel *lkc;
 
+       assert(chan);
+
        lkc = zmalloc(sizeof(struct ltt_kernel_channel));
        if (lkc == NULL) {
                PERROR("ltt_kernel_channel zmalloc");
@@ -191,6 +187,8 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev)
        struct ltt_kernel_event *lke;
        struct lttng_kernel_event *attr;
 
+       assert(ev);
+
        lke = zmalloc(sizeof(struct ltt_kernel_event));
        attr = zmalloc(sizeof(struct lttng_kernel_event));
        if (lke == NULL || attr == NULL) {
@@ -302,6 +300,8 @@ struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
        int ret;
        struct ltt_kernel_stream *lks;
 
+       assert(name);
+
        lks = zmalloc(sizeof(struct ltt_kernel_stream));
        if (lks == NULL) {
                PERROR("kernel stream zmalloc");
@@ -331,6 +331,8 @@ error:
  */
 void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream)
 {
+       assert(stream);
+
        DBG("[trace] Closing stream fd %d", stream->fd);
        /* Close kernel fd */
        if (stream->fd >= 0) {
@@ -352,6 +354,8 @@ void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream)
  */
 void trace_kernel_destroy_event(struct ltt_kernel_event *event)
 {
+       assert(event);
+
        if (event->fd >= 0) {
                int ret;
 
@@ -381,6 +385,8 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel)
        struct ltt_kernel_event *event, *etmp;
        int ret;
 
+       assert(channel);
+
        DBG("[trace] Closing channel fd %d", channel->fd);
        /* Close kernel fd */
        if (channel->fd >= 0) {
@@ -413,6 +419,8 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel)
  */
 void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata)
 {
+       assert(metadata);
+
        DBG("[trace] Closing metadata fd %d", metadata->fd);
        /* Close kernel fd */
        if (metadata->fd >= 0) {
@@ -436,6 +444,8 @@ void trace_kernel_destroy_session(struct ltt_kernel_session *session)
        struct ltt_kernel_channel *channel, *ctmp;
        int ret;
 
+       assert(session);
+
        DBG("[trace] Closing session fd %d", session->fd);
        /* Close kernel fds */
        if (session->fd >= 0) {
index 3d9390db22395885cc1f62e62c90bf9167040b93..1830763b1b6a88d3c1ac7ba528d5512b3e7444a3 100644 (file)
@@ -262,6 +262,9 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan,
        int ret;
        struct ltt_ust_channel *luc;
 
+       assert(chan);
+       assert(path);
+
        luc = zmalloc(sizeof(struct ltt_ust_channel));
        if (luc == NULL) {
                PERROR("ltt_ust_channel zmalloc");
@@ -322,6 +325,8 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
 {
        struct ltt_ust_event *lue;
 
+       assert(ev);
+
        lue = zmalloc(sizeof(struct ltt_ust_event));
        if (lue == NULL) {
                PERROR("ust event zmalloc");
@@ -396,6 +401,8 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
        int ret;
        struct ltt_ust_metadata *lum;
 
+       assert(path);
+
        lum = zmalloc(sizeof(struct ltt_ust_metadata));
        if (lum == NULL) {
                PERROR("ust metadata zmalloc");
@@ -437,6 +444,8 @@ struct ltt_ust_context *trace_ust_create_context(
        struct ltt_ust_context *uctx;
        enum lttng_ust_context_type utype;
 
+       assert(ctx);
+
        switch (ctx->ctx) {
        case LTTNG_EVENT_CONTEXT_VTID:
                utype = LTTNG_UST_CONTEXT_VTID;
@@ -492,6 +501,8 @@ static void destroy_contexts(struct lttng_ht *ht)
        struct lttng_ht_node_ulong *node;
        struct lttng_ht_iter iter;
 
+       assert(ht);
+
        cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) {
                ret = lttng_ht_del(ht, &iter);
                if (!ret) {
@@ -507,6 +518,8 @@ static void destroy_contexts(struct lttng_ht *ht)
  */
 void trace_ust_destroy_event(struct ltt_ust_event *event)
 {
+       assert(event);
+
        DBG2("Trace destroy UST event %s", event->attr.name);
        free(event->filter);
        free(event);
@@ -534,6 +547,8 @@ static void destroy_events(struct lttng_ht *events)
        struct lttng_ht_node_str *node;
        struct lttng_ht_iter iter;
 
+       assert(events);
+
        cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
                ret = lttng_ht_del(events, &iter);
                assert(!ret);
@@ -548,6 +563,8 @@ static void destroy_events(struct lttng_ht *events)
  */
 void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
 {
+       assert(channel);
+
        DBG2("Trace destroy UST channel %s", channel->name);
 
        rcu_read_lock();
@@ -580,6 +597,8 @@ static void destroy_channel_rcu(struct rcu_head *head)
  */
 void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
 {
+       assert(metadata);
+
        if (!metadata->handle) {
                return;
        }
@@ -596,6 +615,8 @@ static void destroy_channels(struct lttng_ht *channels)
        struct lttng_ht_node_str *node;
        struct lttng_ht_iter iter;
 
+       assert(channels);
+
        rcu_read_lock();
 
        cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) {
@@ -618,6 +639,8 @@ static void destroy_domain_pid(struct lttng_ht *ht)
        struct lttng_ht_iter iter;
        struct ltt_ust_domain_pid *dpid;
 
+       assert(ht);
+
        cds_lfht_for_each_entry(ht->ht, &iter.iter, dpid, node.node) {
                ret = lttng_ht_del(ht , &iter);
                assert(!ret);
@@ -636,6 +659,8 @@ static void destroy_domain_exec(struct lttng_ht *ht)
        struct lttng_ht_iter iter;
        struct ltt_ust_domain_exec *dexec;
 
+       assert(ht);
+
        cds_lfht_for_each_entry(ht->ht, &iter.iter, dexec, node.node) {
                ret = lttng_ht_del(ht , &iter);
                assert(!ret);
@@ -650,6 +675,8 @@ static void destroy_domain_exec(struct lttng_ht *ht)
  */
 static void destroy_domain_global(struct ltt_ust_domain_global *dom)
 {
+       assert(dom);
+
        destroy_channels(dom->channels);
 }
 
@@ -658,10 +685,7 @@ static void destroy_domain_global(struct ltt_ust_domain_global *dom)
  */
 void trace_ust_destroy_session(struct ltt_ust_session *session)
 {
-       /* Extra protection */
-       if (session == NULL) {
-               return;
-       }
+       assert(session);
 
        rcu_read_lock();
 
index efe19ecdc08cd516aff7426277e21bef11eb7c88..a6d76c73df49a96a8300f4ca3834811e9d87c441 100644 (file)
@@ -203,22 +203,6 @@ static int fuzzing_create_args(void)
        return 0;
 }
 
-static int fuzzing_destroy_args(void)
-{
-       int ret;
-
-       ret = destroy_one_session(NULL);
-       if (ret > 0) {
-               printf("Session destroyed with (null)\n");
-               return -1;
-       }
-
-       /* Session list must be 0 */
-       assert(!session_list_count());
-
-       return 0;
-}
-
 /*
  * This test is supposed to fail at the second create call. If so, return 0 for
  * test success, else -1.
@@ -307,14 +291,6 @@ int main(int argc, char **argv)
        }
        PRINT_OK();
 
-       printf("Fuzzing destroy_session argument: ");
-       fflush(stdout);
-       ret = fuzzing_destroy_args();
-       if (ret < 0) {
-               return -1;
-       }
-       PRINT_OK();
-
        printf("Creating %d sessions: ", MAX_SESSIONS);
        fflush(stdout);
        for (i = 0; i < MAX_SESSIONS; i++) {
This page took 0.035994 seconds and 4 git commands to generate.