Minor code cleanup
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 13 Apr 2011 21:56:21 +0000 (17:56 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 13 Apr 2011 21:56:21 +0000 (17:56 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttsessiondcomm/liblttsessiondcomm.c
liblttsessiondcomm/liblttsessiondcomm.h
ltt-sessiond/ltt-sessiond.c
ltt-sessiond/ltt-sessiond.h

index 9c72a918ccc23d94584df20a3d0bb139b5ce7c6a..581d5c4199a23d69de3f21e0e73ba60e76dba7c5 100644 (file)
@@ -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;
index b52d1dd5b5c19655e617967e773d49ef9d14a15f..0e2c4f07f8814b0c290e1366b8861b7a3fd4e71c 100644 (file)
@@ -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,
index e7b8db7dd84a61b85c445a648666327c28dc778d..6877acccbef7b8f106685c268679381c714c095f 100644 (file)
 #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;
        }
index 591e83104f3c100c2dce3f0a188950b2c33aebcc..cff3ae75472aa2b79627012e77ef4d437cff8383 100644 (file)
 #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 {
This page took 0.029324 seconds and 4 git commands to generate.