From 686204ab689fc20afc4aaf014f1f4a877b1e581d Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 13 Apr 2011 17:56:21 -0400 Subject: [PATCH] Minor code cleanup Signed-off-by: Mathieu Desnoyers --- liblttsessiondcomm/liblttsessiondcomm.c | 22 +++++++++++----------- liblttsessiondcomm/liblttsessiondcomm.h | 2 +- ltt-sessiond/ltt-sessiond.c | 16 +++++++++++----- ltt-sessiond/ltt-sessiond.h | 13 +++++++++---- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/liblttsessiondcomm/liblttsessiondcomm.c b/liblttsessiondcomm/liblttsessiondcomm.c index 9c72a918c..581d5c419 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.c +++ b/liblttsessiondcomm/liblttsessiondcomm.c @@ -67,27 +67,27 @@ const char *lttcomm_get_readable_code(enum lttcomm_return_code code) */ int lttcomm_connect_unix_sock(const char *pathname) { - struct sockaddr_un sun; - int fd; + struct sockaddr_un sun; + int fd; int ret = 1; - fd = socket(PF_UNIX, SOCK_STREAM, 0); + fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); goto error; } - memset(&sun, 0, sizeof(sun)); - sun.sun_family = AF_UNIX; - strncpy(sun.sun_path, pathname, sizeof(sun.sun_path)); + memset(&sun, 0, sizeof(sun)); + sun.sun_family = AF_UNIX; + strncpy(sun.sun_path, pathname, sizeof(sun.sun_path)); - ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun)); - if (ret < 0) { - perror("connect"); + ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun)); + if (ret < 0) { + perror("connect"); goto error; - } + } - return fd; + return fd; error: return -1; diff --git a/liblttsessiondcomm/liblttsessiondcomm.h b/liblttsessiondcomm/liblttsessiondcomm.h index b52d1dd5b..0e2c4f07f 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.h +++ b/liblttsessiondcomm/liblttsessiondcomm.h @@ -39,7 +39,7 @@ /* Get the error code index from 0 since * LTTCOMM_OK start at 1000 */ -#define LTTCOMM_ERR_INDEX(code) code - LTTCOMM_OK +#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK) enum lttcomm_command_type { LTTNG_CREATE_SESSION, diff --git a/ltt-sessiond/ltt-sessiond.c b/ltt-sessiond/ltt-sessiond.c index e7b8db7dd..6877acccb 100644 --- a/ltt-sessiond/ltt-sessiond.c +++ b/ltt-sessiond/ltt-sessiond.c @@ -39,6 +39,11 @@ #include "liblttsessiondcomm.h" #include "ltt-sessiond.h" +const char default_home_dir[] = DEFAULT_HOME_DIR; +const char default_tracing_group[] = DEFAULT_TRACING_GROUP; +const char default_ust_sock_dir[] = DEFAULT_UST_SOCK_DIR; +const char default_global_apps_pipe[] = DEFAULT_GLOBAL_APPS_PIPE; + /* Static functions */ static int set_signal_handler(void); static int set_socket_perms(void); @@ -94,11 +99,11 @@ static void *thread_manage_apps(void *data) struct ltt_traceable_app *lta; /* TODO: Something more elegant is needed but fine for now */ - struct { + struct { int reg; /* 1:register, 0:unregister */ - pid_t pid; - uid_t uid; - } reg_msg; + pid_t pid; + uid_t uid; + } reg_msg; /* Notify all applications to register */ notify_apps(default_global_apps_pipe); @@ -595,7 +600,7 @@ static const char *get_home_dir(void) { const char *home_path; - if ((home_path = (const char*) getenv("HOME")) == NULL) { + if ((home_path = (const char *) getenv("HOME")) == NULL) { home_path = default_home_dir; } @@ -724,6 +729,7 @@ static void sighandler(int sig) case SIGINT: case SIGTERM: cleanup(); + break; default: break; } diff --git a/ltt-sessiond/ltt-sessiond.h b/ltt-sessiond/ltt-sessiond.h index 591e83104..cff3ae754 100644 --- a/ltt-sessiond/ltt-sessiond.h +++ b/ltt-sessiond/ltt-sessiond.h @@ -19,10 +19,15 @@ #ifndef _LTT_SESSIOND_H #define _LTT_SESSIOND_H -const char default_home_dir[] = "/tmp"; -const char default_tracing_group[] = "tracing"; -const char default_ust_sock_dir[] = "/tmp/ust-app-socks"; -const char default_global_apps_pipe[] = "/tmp/ust-app-socks/global"; +#define DEFAULT_HOME_DIR "/tmp" +#define DEFAULT_TRACING_GROUP "/tracing" +#define DEFAULT_UST_SOCK_DIR "/tmp/ust-app-socks" +#define DEFAULT_GLOBAL_APPS_PIPE "/tmp/ust-app-socks/global" + +extern const char default_home_dir[], + default_tracing_group[], + default_ust_sock_dir[], + default_global_apps_pipe[]; /* LTTng trace representation */ struct ltt_lttng_trace { -- 2.34.1