Fix: move memset in channel_set_attr after NULL check
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 36069ef2816b7906bb9f19a8c0714912a8061f31..a1256e12d981aa5da93c7aed8f7784e24732be9b 100644 (file)
@@ -680,6 +680,33 @@ int lttng_list_tracepoints(struct lttng_handle *handle,
        return ret / sizeof(struct lttng_event);
 }
 
+/*
+ *  Lists all available tracepoint fields of domain.
+ *  Sets the contents of the event field array.
+ *  Returns the number of lttng_event_field entries in events;
+ *  on error, returns a negative value.
+ */
+int lttng_list_tracepoint_fields(struct lttng_handle *handle,
+               struct lttng_event_field **fields)
+{
+       int ret;
+       struct lttcomm_session_msg lsm;
+
+       if (handle == NULL) {
+               return -1;
+       }
+
+       lsm.cmd_type = LTTNG_LIST_TRACEPOINT_FIELDS;
+       copy_lttng_domain(&lsm.domain, &handle->domain);
+
+       ret = ask_sessiond(&lsm, (void **) fields);
+       if (ret < 0) {
+               return ret;
+       }
+
+       return ret / sizeof(struct lttng_event_field);
+}
+
 /*
  *  Returns a human readable string describing
  *  the error code (a negative value).
@@ -885,13 +912,13 @@ int lttng_calibrate(struct lttng_handle *handle,
 void lttng_channel_set_default_attr(struct lttng_domain *domain,
                struct lttng_channel_attr *attr)
 {
-       memset(attr, 0, sizeof(struct lttng_channel_attr));
-
        /* Safety check */
        if (attr == NULL || domain == NULL) {
                return;
        }
 
+       memset(attr, 0, sizeof(struct lttng_channel_attr));
+
        switch (domain->type) {
        case LTTNG_DOMAIN_KERNEL:
                attr->overwrite = DEFAULT_CHANNEL_OVERWRITE;
This page took 0.024291 seconds and 4 git commands to generate.