X-Git-Url: http://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl-health.c;h=dc1516db5d0c7336371e10f0408927eef34a949e;hp=9ae3d4174969e666f13ad56cfe8240e3a147d237;hb=e1b624d005769d1a2e9eb39fee63c73c6395fd76;hpb=43ed148559609eba941bb3dffa35bff67341e64d diff --git a/src/lib/lttng-ctl/lttng-ctl-health.c b/src/lib/lttng-ctl/lttng-ctl-health.c index 9ae3d4174..dc1516db5 100644 --- a/src/lib/lttng-ctl/lttng-ctl-health.c +++ b/src/lib/lttng-ctl/lttng-ctl-health.c @@ -94,7 +94,7 @@ const char **thread_name[NR_HEALTH_COMPONENT] = { /* * Set health socket path. * - * Returns 0 on success or -ENOMEM. + * Returns 0 on success or a negative errno. */ static int set_health_socket_path(struct lttng_health *lh, @@ -143,10 +143,10 @@ int set_health_socket_path(struct lttng_health *lh, uid = getuid(); if (uid == 0 || tracing_group) { - lttng_ctl_copy_string(lh->health_sock_path, + ret = lttng_strncpy(lh->health_sock_path, global_str, sizeof(lh->health_sock_path)); - return 0; + return ret == 0 ? 0 : -EINVAL; } /* @@ -218,20 +218,30 @@ struct lttng_health * struct lttng_health *lttng_health_create_relayd(const char *path) { - struct lttng_health *lh; + int ret; + struct lttng_health *lh = NULL; if (!path) { - return NULL; + goto error; } lh = lttng_health_create(HEALTH_COMPONENT_RELAYD, NR_HEALTH_RELAYD_TYPES); if (!lh) { - return NULL; + goto error; } - lttng_ctl_copy_string(lh->health_sock_path, path, - sizeof(lh->health_sock_path)); + + ret = lttng_strncpy(lh->health_sock_path, path ?: "", + sizeof(lh->health_sock_path)); + if (ret) { + goto error; + } + return lh; + +error: + free(lh); + return NULL; } void lttng_health_destroy(struct lttng_health *lh)