From: Jérémie Galarneau Date: Thu, 30 Nov 2017 23:23:44 +0000 (+0100) Subject: Clean-up: reduce scope of dyanamically-allocated string X-Git-Tag: v2.11.0-rc1~420 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=ddaec4a2b9b7c8be74166525bdcdff115c80d7c4 Clean-up: reduce scope of dyanamically-allocated string tmpnew is only useful within the scope of the libdir check. It can be allocated and free()'d within that scope. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 297db20ce..4c3a1796c 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2440,11 +2440,10 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) break; case LTTNG_CONSUMER64_UST: { - char *tmpnew = NULL; - if (config.consumerd64_lib_dir.value) { char *tmp; size_t tmplen; + char *tmpnew; tmp = lttng_secure_getenv("LD_LIBRARY_PATH"); if (!tmp) { @@ -2462,9 +2461,9 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) strcat(tmpnew, tmp); } ret = setenv("LD_LIBRARY_PATH", tmpnew, 1); + free(tmpnew); if (ret) { ret = -errno; - free(tmpnew); goto error; } } @@ -2474,16 +2473,14 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) "--consumerd-err-sock", consumer_data->err_unix_sock_path, "--group", config.tracing_group_name.value, NULL); - free(tmpnew); break; } case LTTNG_CONSUMER32_UST: { - char *tmpnew = NULL; - if (config.consumerd32_lib_dir.value) { char *tmp; size_t tmplen; + char *tmpnew; tmp = lttng_secure_getenv("LD_LIBRARY_PATH"); if (!tmp) { @@ -2501,9 +2498,9 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) strcat(tmpnew, tmp); } ret = setenv("LD_LIBRARY_PATH", tmpnew, 1); + free(tmpnew); if (ret) { ret = -errno; - free(tmpnew); goto error; } } @@ -2513,7 +2510,6 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) "--consumerd-err-sock", consumer_data->err_unix_sock_path, "--group", config.tracing_group_name.value, NULL); - free(tmpnew); break; } default: