Initialize all stack variables to zero, fix uninitialized loglevel variables
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 1d92facf05cf866ee757a0acc247b5f0225e8b0c..dafe085dc9bc40b81f53a35b13fbc6791969492f 100644 (file)
@@ -74,6 +74,7 @@ static void copy_lttng_domain(struct lttng_domain *dst, struct lttng_domain *src
                                memcpy(dst, src, sizeof(struct lttng_domain));
                                break;
                        default:
+                               memset(dst, 0, sizeof(struct lttng_domain));
                                dst->type = LTTNG_DOMAIN_KERNEL;
                                break;
                }
@@ -484,6 +485,8 @@ int lttng_add_context(struct lttng_handle *handle,
                return -1;
        }
 
+       memset(&lsm, 0, sizeof(lsm));
+
        lsm.cmd_type = LTTNG_ADD_CONTEXT;
 
        /* Copy channel name */
@@ -518,6 +521,8 @@ int lttng_enable_event(struct lttng_handle *handle,
                return -1;
        }
 
+       memset(&lsm, 0, sizeof(lsm));
+
        /* If no channel name, we put the default name */
        if (channel_name == NULL) {
                copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME,
@@ -557,6 +562,8 @@ int lttng_disable_event(struct lttng_handle *handle, const char *name,
                return -1;
        }
 
+       memset(&lsm, 0, sizeof(lsm));
+
        if (channel_name) {
                copy_string(lsm.u.disable.channel_name, channel_name,
                                sizeof(lsm.u.disable.channel_name));
@@ -596,6 +603,8 @@ int lttng_enable_channel(struct lttng_handle *handle,
                return -1;
        }
 
+       memset(&lsm, 0, sizeof(lsm));
+
        memcpy(&lsm.u.channel.chan, chan, sizeof(lsm.u.channel.chan));
 
        lsm.cmd_type = LTTNG_ENABLE_CHANNEL;
@@ -621,6 +630,8 @@ int lttng_disable_channel(struct lttng_handle *handle, const char *name)
                return -1;
        }
 
+       memset(&lsm, 0, sizeof(lsm));
+
        lsm.cmd_type = LTTNG_DISABLE_CHANNEL;
 
        copy_string(lsm.u.disable.channel_name, name,
@@ -861,11 +872,13 @@ int lttng_calibrate(struct lttng_handle *handle,
 
 /*
  * Set default channel attributes.
- * If either or both of the arguments are null, nothing happens.
+ * If either or both of the arguments are null, attr content is zeroe'd.
  */
 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;
@@ -896,8 +909,7 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,
                attr->output = DEFAULT_UST_CHANNEL_OUTPUT;
                break;
        default:
-               /* Default behavior */
-               memset(attr, 0, sizeof(struct lttng_channel_attr));
+               /* Default behavior: leave set to 0. */
                break;
        }
 }
This page took 0.025442 seconds and 5 git commands to generate.