projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean-up: reduce scope of dyanamically-allocated string
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
main.c
diff --git
a/src/bin/lttng-sessiond/main.c
b/src/bin/lttng-sessiond/main.c
index 10802aa7b2cc66d87d0946ee53623b05b47a1c0f..4c3a1796c8aa58abac502fbee00195b68c0d262d 100644
(file)
--- a/
src/bin/lttng-sessiond/main.c
+++ b/
src/bin/lttng-sessiond/main.c
@@
-2413,9
+2413,9
@@
static pid_t spawn_consumerd(struct consumer_data *consumer_data)
* fallback on the 32-bit one,
*/
DBG3("Looking for a kernel consumer at these locations:");
* fallback on the 32-bit one,
*/
DBG3("Looking for a kernel consumer at these locations:");
- DBG3(" 1) %s", config.consumerd64_bin_path.value);
+ DBG3(" 1) %s", config.consumerd64_bin_path.value
? : "NULL"
);
DBG3(" 2) %s/%s", INSTALL_BIN_PATH, DEFAULT_CONSUMERD_FILE);
DBG3(" 2) %s/%s", INSTALL_BIN_PATH, DEFAULT_CONSUMERD_FILE);
- DBG3(" 3) %s", config.consumerd32_bin_path.value);
+ DBG3(" 3) %s", config.consumerd32_bin_path.value
? : "NULL"
);
if (stat(config.consumerd64_bin_path.value, &st) == 0) {
DBG3("Found location #1");
consumer_to_use = config.consumerd64_bin_path.value;
if (stat(config.consumerd64_bin_path.value, &st) == 0) {
DBG3("Found location #1");
consumer_to_use = config.consumerd64_bin_path.value;
@@
-2440,33
+2440,30
@@
static pid_t spawn_consumerd(struct consumer_data *consumer_data)
break;
case LTTNG_CONSUMER64_UST:
{
break;
case LTTNG_CONSUMER64_UST:
{
- char *tmpnew = NULL;
-
- if (config.consumerd64_lib_dir.value[0] != '\0') {
+ if (config.consumerd64_lib_dir.value) {
char *tmp;
size_t tmplen;
char *tmp;
size_t tmplen;
+ char *tmpnew;
tmp = lttng_secure_getenv("LD_LIBRARY_PATH");
if (!tmp) {
tmp = "";
}
tmp = lttng_secure_getenv("LD_LIBRARY_PATH");
if (!tmp) {
tmp = "";
}
- tmplen = strlen("LD_LIBRARY_PATH=")
- + strlen(config.consumerd64_lib_dir.value) + 1 /* : */ + strlen(tmp);
+ tmplen = strlen(config.consumerd64_lib_dir.value) + 1 /* : */ + strlen(tmp);
tmpnew = zmalloc(tmplen + 1 /* \0 */);
if (!tmpnew) {
ret = -ENOMEM;
goto error;
}
tmpnew = zmalloc(tmplen + 1 /* \0 */);
if (!tmpnew) {
ret = -ENOMEM;
goto error;
}
- strcpy(tmpnew, "LD_LIBRARY_PATH=");
strcat(tmpnew, config.consumerd64_lib_dir.value);
if (tmp[0] != '\0') {
strcat(tmpnew, ":");
strcat(tmpnew, tmp);
}
strcat(tmpnew, config.consumerd64_lib_dir.value);
if (tmp[0] != '\0') {
strcat(tmpnew, ":");
strcat(tmpnew, tmp);
}
- ret = putenv(tmpnew);
+ ret = setenv("LD_LIBRARY_PATH", tmpnew, 1);
+ free(tmpnew);
if (ret) {
ret = -errno;
if (ret) {
ret = -errno;
- free(tmpnew);
goto error;
}
}
goto error;
}
}
@@
-2476,40
+2473,34
@@
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);
"--consumerd-err-sock", consumer_data->err_unix_sock_path,
"--group", config.tracing_group_name.value,
NULL);
- if (config.consumerd64_lib_dir.value[0] != '\0') {
- free(tmpnew);
- }
break;
}
case LTTNG_CONSUMER32_UST:
{
break;
}
case LTTNG_CONSUMER32_UST:
{
- char *tmpnew = NULL;
-
- if (config.consumerd32_lib_dir.value[0] != '\0') {
+ if (config.consumerd32_lib_dir.value) {
char *tmp;
size_t tmplen;
char *tmp;
size_t tmplen;
+ char *tmpnew;
tmp = lttng_secure_getenv("LD_LIBRARY_PATH");
if (!tmp) {
tmp = "";
}
tmp = lttng_secure_getenv("LD_LIBRARY_PATH");
if (!tmp) {
tmp = "";
}
- tmplen = strlen("LD_LIBRARY_PATH=")
- + strlen(config.consumerd32_lib_dir.value) + 1 /* : */ + strlen(tmp);
+ tmplen = strlen(config.consumerd32_lib_dir.value) + 1 /* : */ + strlen(tmp);
tmpnew = zmalloc(tmplen + 1 /* \0 */);
if (!tmpnew) {
ret = -ENOMEM;
goto error;
}
tmpnew = zmalloc(tmplen + 1 /* \0 */);
if (!tmpnew) {
ret = -ENOMEM;
goto error;
}
- strcpy(tmpnew, "LD_LIBRARY_PATH=");
strcat(tmpnew, config.consumerd32_lib_dir.value);
if (tmp[0] != '\0') {
strcat(tmpnew, ":");
strcat(tmpnew, tmp);
}
strcat(tmpnew, config.consumerd32_lib_dir.value);
if (tmp[0] != '\0') {
strcat(tmpnew, ":");
strcat(tmpnew, tmp);
}
- ret = putenv(tmpnew);
+ ret = setenv("LD_LIBRARY_PATH", tmpnew, 1);
+ free(tmpnew);
if (ret) {
ret = -errno;
if (ret) {
ret = -errno;
- free(tmpnew);
goto error;
}
}
goto error;
}
}
@@
-2519,14
+2510,11
@@
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);
"--consumerd-err-sock", consumer_data->err_unix_sock_path,
"--group", config.tracing_group_name.value,
NULL);
- if (config.consumerd32_lib_dir.value[0] != '\0') {
- free(tmpnew);
- }
break;
}
default:
break;
}
default:
-
PERRO
R("unknown consumer type");
- e
xit(EXIT_FAILURE)
;
+
ER
R("unknown consumer type");
+ e
rrno = 0
;
}
if (errno != 0) {
PERROR("Consumer execl()");
}
if (errno != 0) {
PERROR("Consumer execl()");
@@
-5584,12
+5572,13
@@
int main(int argc, char **argv)
/* Check if daemon is UID = 0 */
is_root = !getuid();
/* Check if daemon is UID = 0 */
is_root = !getuid();
+ if (create_lttng_rundir()) {
+ retval = -1;
+ goto exit_init_data;
+ }
+
if (is_root) {
/* Create global run dir with root access */
if (is_root) {
/* Create global run dir with root access */
- if (create_lttng_rundir()) {
- retval = -1;
- goto exit_init_data;
- }
kernel_channel_monitor_pipe = lttng_pipe_open(0);
if (!kernel_channel_monitor_pipe) {
kernel_channel_monitor_pipe = lttng_pipe_open(0);
if (!kernel_channel_monitor_pipe) {
This page took
0.027872 seconds
and
5
git commands to generate.