fix: if tracing group does not exist, do not report a client error
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 1d92facf05cf866ee757a0acc247b5f0225e8b0c..c5887fe65ead21a41f637aafa3adc10d60e0eb45 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;
                }
@@ -137,11 +138,8 @@ static int check_tracing_group(const char *grp_name)
 
        /* Get GID of group 'tracing' */
        grp_tracing = getgrnam(grp_name);
-       if (grp_tracing == NULL) {
-               /* NULL means not found also. getgrnam(3) */
-               if (errno != 0) {
-                       perror("getgrnam");
-               }
+       if (!grp_tracing) {
+               /* If grp_tracing is NULL, the group does not exist. */
                goto end;
        }
 
@@ -484,6 +482,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 +518,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 +559,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 +600,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 +627,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 +869,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 +906,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.024336 seconds and 4 git commands to generate.