From: David Goulet Date: Tue, 26 Apr 2011 19:11:25 +0000 (-0400) Subject: Clean some part of the code X-Git-Tag: v2.0-pre1~182 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1fd70b72ff7f1c98e4629392236d76ca9083295f;p=lttng-tools.git Clean some part of the code Add goto to send data in the process client command. Signed-off-by: David Goulet --- diff --git a/ltt-sessiond/ltt-sessiond.c b/ltt-sessiond/ltt-sessiond.c index 5a6c5dc97..2dcf62f45 100644 --- a/ltt-sessiond/ltt-sessiond.c +++ b/ltt-sessiond/ltt-sessiond.c @@ -50,12 +50,12 @@ const char default_global_apps_pipe[] = DEFAULT_GLOBAL_APPS_PIPE; /* Static functions */ static int set_signal_handler(void); static int set_socket_perms(void); -static void sighandler(int); +static void sighandler(int sig); static void cleanup(void); static void copy_common_data(struct lttcomm_lttng_msg *llm, struct lttcomm_session_msg *lsm); static int check_existing_daemon(void); -static int notify_apps(const char*); -static int connect_app(pid_t); +static int notify_apps(const char* name); +static int connect_app(pid_t pid); static int init_daemon_socket(void); static int process_client_msg(int sock, struct lttcomm_session_msg*); static int send_unix_sock(int sock, void *buf, size_t len); @@ -65,13 +65,13 @@ static int setup_data_buffer(char **buf, size_t size, struct lttcomm_lttng_msg * static void get_list_apps(pid_t *pids); static void get_list_sessions(struct lttng_session *lt); -static void *thread_manage_clients(void *); -static void *thread_manage_apps(void *); +static void *thread_manage_clients(void *data); +static void *thread_manage_apps(void *data); static int create_session(char *name, uuid_t *session_id); -static void destroy_session(uuid_t); +static void destroy_session(uuid_t session_id); -static struct ltt_session *find_session(uuid_t); +static struct ltt_session *find_session(uuid_t session_id); /* Variables */ const char *progname; @@ -540,11 +540,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) goto error; } - ret = send_unix_sock(sock, send_buf, buf_size); - if (ret < 0) { - goto send_error; - } - + goto send; break; } case UST_LIST_APPS: @@ -565,11 +561,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) get_list_apps((pid_t *)(send_buf + sizeof(struct lttcomm_lttng_msg))); - ret = send_unix_sock(sock, send_buf, buf_size); - if (ret < 0) { - goto send_error; - } - + goto send; break; } case LTTNG_LIST_SESSIONS: @@ -590,11 +582,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) get_list_sessions((struct lttng_session *)(send_buf + sizeof(struct lttcomm_lttng_msg))); - ret = send_unix_sock(sock, send_buf, buf_size); - if (ret < 0) { - goto send_error; - } - + goto send; break; } default: @@ -605,13 +593,13 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) } } +send: + ret = send_unix_sock(sock, send_buf, buf_size); + if (send_buf != NULL) { free(send_buf); } - return 0; - -send_error: return ret; error: