cleanups
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 8 Sep 2009 18:01:17 +0000 (14:01 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 8 Sep 2009 18:02:09 +0000 (14:02 -0400)
libust/relay.c
libust/serialize.c
libust/tracectl.c
libustcmd/ustcmd.c
libustcmd/ustcmd.h
libustcomm/ustcomm.c
libustcomm/ustcomm.h
share/kernelcompat.h
ust/ust.c

index 1235a9a7cd481a17dd5dd9adc3bebed76e879826..05399b4a75787acb512eb30e09d6a721f80526a8 100644 (file)
@@ -2466,8 +2466,6 @@ static /* inline */ void ltt_write_commit_counter(struct rchan_buf *buf,
         */
        ltt_write_commit_counter(buf, ltt_buf, endidx,
                                 buf_offset, commit_count, data_size);
-
-       DBG("commited slot. now commit count is %ld", commit_count);
 }
 
 
index 238bd257aebefff6861eaa231786410460b2f8f6..2fe6db779e106d59aa21c50969a7d7bc75766ed2 100644 (file)
@@ -689,7 +689,7 @@ notrace void ltt_vtrace(const struct marker *mdata, void *probe_data,
                /* Out-of-order commit */
                ltt_commit_slot(channel, &transport_data, buf_offset,
                                data_size, slot_size);
-               DBG("just commited event at offset %ld and size %zd\n", buf_offset, slot_size);
+               DBG("just commited event at offset %ld and size %zd", buf_offset, slot_size);
        }
 //ust//        __get_cpu_var(ltt_nesting)--;
        ltt_nesting--;
index 533cc6599639bb5750d4f4437600c2b407a2e0f3..7c65e3f82119496c6a608283c78c27ab1cc8eff4 100644 (file)
@@ -253,7 +253,7 @@ void *listener_main(void *p)
                        continue;
                }
 
-               DBG("received a message! it's: %s\n", recvbuf);
+               DBG("received a message! it's: %s", recvbuf);
                len = strlen(recvbuf);
 
                if(!strcmp(recvbuf, "print_markers")) {
@@ -875,7 +875,7 @@ static void __attribute__((constructor(1000))) init()
        if(autoprobe_val) {
                struct marker_iter iter;
 
-               DBG("Autoprobe enabled.\n");
+               DBG("Autoprobe enabled.");
 
                /* Ensure markers are initialized */
                //init_markers();
@@ -910,9 +910,9 @@ static void __attribute__((constructor(1000))) init()
                marker_iter_reset(&iter);
                marker_iter_start(&iter);
 
-               DBG("now iterating on markers already registered\n");
+               DBG("now iterating on markers already registered");
                while(iter.marker) {
-                       DBG("now iterating on marker %s\n", iter.marker->name);
+                       DBG("now iterating on marker %s", iter.marker->name);
                        auto_probe_connect(iter.marker);
                        marker_iter_next(&iter);
                }
index 223280cc238201130166b94f3399e447913b21c4..bbb6928c3bff3fda77e02b380d93305d75b9e9cb 100644 (file)
 #include "ustcomm.h"
 #include "ustcmd.h"
 
-#define _GNU_SOURCE
-
-pid_t* ustcmd_get_online_pids(void)
+pid_t *ustcmd_get_online_pids(void)
 {
-       struct direntdirent;
-       DIRdir;
+       struct dirent *dirent;
+       DIR *dir;
        unsigned int ret_size = 1 * sizeof(pid_t), i = 0;
 
        dir = opendir(SOCK_DIR);
@@ -40,7 +38,7 @@ pid_t* ustcmd_get_online_pids(void)
                return NULL;
        }
 
-       pid_t* ret = (pid_t*) malloc(ret_size);
+       pid_t *ret = (pid_t *) malloc(ret_size);
 
        while ((dirent = readdir(dir))) {
                if (!strcmp(dirent->d_name, ".") ||
@@ -52,10 +50,10 @@ pid_t* ustcmd_get_online_pids(void)
                if (dirent->d_type != DT_DIR &&
                        !!strcmp(dirent->d_name, "ustd")) {
 
-                       sscanf(dirent->d_name, "%u", (unsigned int*) &ret[i]);
+                       sscanf(dirent->d_name, "%u", (unsigned int *) &ret[i]);
                        if (pid_is_online(ret[i])) {
                                ret_size += sizeof(pid_t);
-                               ret = (pid_t*) realloc(ret, ret_size);
+                               ret = (pid_t *) realloc(ret, ret_size);
                                ++i;
                        }
                }
@@ -63,7 +61,8 @@ pid_t* ustcmd_get_online_pids(void)
 
        ret[i] = 0; /* Array end */
 
-       if (ret[0] == 0) { /* No PID at all.. */
+       if (ret[0] == 0) {
+                /* No PID at all */
                free(ret);
                return NULL;
        }
@@ -80,10 +79,10 @@ pid_t* ustcmd_get_online_pids(void)
  * @param pid  Traced process ID
  * @return     0 if successful, or errors {USTCMD_ERR_GEN, USTCMD_ERR_ARG}
  */
-int ustcmd_set_marker_state(const charmn, int state, pid_t pid)
+int ustcmd_set_marker_state(const char *mn, int state, pid_t pid)
 {
-       charcmd_str [] = {"disable_marker", "enable_marker"};
-       charcmd;
+       char *cmd_str [] = {"disable_marker", "enable_marker"};
+       char *cmd;
        int result;
 
        if (mn == NULL) {
@@ -92,7 +91,7 @@ int ustcmd_set_marker_state(const char* mn, int state, pid_t pid)
 
        asprintf(&cmd, "%s %s", cmd_str[state], mn);
 
-       result = ustcmd_shoot(cmd, pid, NULL);
+       result = ustcmd_send_cmd(cmd, pid, NULL);
        if (result) {
                free(cmd);
                return USTCMD_ERR_GEN;
@@ -112,7 +111,7 @@ int ustcmd_destroy_trace(pid_t pid)
 {
        int result;
 
-       result = ustcmd_shoot("destroy", pid, NULL);
+       result = ustcmd_send_cmd("destroy", pid, NULL);
        if (result) {
                return USTCMD_ERR_GEN;
        }
@@ -130,7 +129,7 @@ int ustcmd_setup_and_start(pid_t pid)
 {
        int result;
 
-       result = ustcmd_shoot("start", pid, NULL);
+       result = ustcmd_send_cmd("start", pid, NULL);
        if (result) {
                return USTCMD_ERR_GEN;
        }
@@ -148,7 +147,7 @@ int ustcmd_start_trace(pid_t pid)
 {
        int result;
 
-       result = ustcmd_shoot("trace_start", pid, NULL);
+       result = ustcmd_send_cmd("trace_start", pid, NULL);
        if (result) {
                return USTCMD_ERR_GEN;
        }
@@ -166,7 +165,7 @@ int ustcmd_stop_trace(pid_t pid)
 {
        int result;
 
-       result = ustcmd_shoot("trace_stop", pid, NULL);
+       result = ustcmd_send_cmd("trace_stop", pid, NULL);
        if (result) {
                return USTCMD_ERR_GEN;
        }
@@ -180,7 +179,7 @@ int ustcmd_stop_trace(pid_t pid)
  * @param str  String to search in
  * @return     Total newlines count
  */
-unsigned int ustcmd_count_nl(const charstr)
+unsigned int ustcmd_count_nl(const char *str)
 {
        unsigned int i = 0, tot = 0;
 
@@ -200,7 +199,7 @@ unsigned int ustcmd_count_nl(const char* str)
  * @param cmsf CMSF array to free
  * @return     0 if successful, or error USTCMD_ERR_ARG
  */
-int ustcmd_free_cmsf(struct USTcmd_cmsf* cmsf)
+int ustcmd_free_cmsf(struct marker_status *cmsf)
 {
        if (cmsf == NULL) {
                return USTCMD_ERR_ARG;
@@ -226,17 +225,17 @@ int ustcmd_free_cmsf(struct USTcmd_cmsf* cmsf)
  * @param pid  Targeted PID
  * @return     0 if successful, or errors {USTCMD_ERR_ARG, USTCMD_ERR_GEN}
  */
-int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid)
+int ustcmd_get_cmsf(struct marker_status **cmsf, const pid_t pid)
 {
-       charbig_str = NULL;
+       char *big_str = NULL;
        int result;
-       struct USTcmd_cmsf* tmp_cmsf = NULL;
+       struct marker_status *tmp_cmsf = NULL;
        unsigned int i = 0, cmsf_ind = 0;
 
        if (cmsf == NULL) {
                return USTCMD_ERR_ARG;
        }
-       result = ustcmd_shoot("list_markers", pid, &big_str);
+       result = ustcmd_send_cmd("list_markers", pid, &big_str);
        if (result) {
                return USTCMD_ERR_GEN;
        }
@@ -246,7 +245,7 @@ int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid)
                return USTCMD_ERR_GEN;
        }
 
-       tmp_cmsf = (struct USTcmd_cmsf*) malloc(sizeof(struct USTcmd_cmsf) *
+       tmp_cmsf = (struct marker_status *) malloc(sizeof(struct marker_status) *
                (ustcmd_count_nl(big_str) + 1));
        if (tmp_cmsf == NULL) {
                return USTCMD_ERR_GEN;
@@ -290,7 +289,7 @@ int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid)
  * @return     0 if successful, or errors {USTCMD_ERR_ARG, USTCMD_ERR_CONN}
  */
 
-int ustcmd_shoot(const char* cmd, const pid_t pid, char** reply)
+int ustcmd_send_cmd(const char *cmd, const pid_t pid, char **reply)
 {
        struct ustcomm_connection conn;
 
@@ -299,7 +298,7 @@ int ustcmd_shoot(const char* cmd, const pid_t pid, char** reply)
        }
 
        if (ustcomm_connect_app(pid, &conn)) {
-               fprintf(stderr, "ustcmd_shoot: could not connect to PID %u\n",
+               fprintf(stderr, "ustcmd_send_cmd: could not connect to PID %u\n",
                        (unsigned int) pid);
                return USTCMD_ERR_CONN;
        }
index 8bca50974bb03c572422382eba5ead88b9f01210..da4718b0943b3d317525355834c062e43a30decb 100644 (file)
 #define USTCMD_SOCK_PATH       "/tmp/socks/"
 
 /* Channel/marker/state/format string (cmsf) info. structure */
-struct USTcmd_cmsf {
-       char* channel; /* Channel name (end of USTcmd_cmsf array if NULL) */
-       char* marker; /* Marker name (end of USTcmd_cmsf array if NULL) */
+struct marker_status {
+       char *channel; /* Channel name (end of marker_status array if NULL) */
+       char *marker; /* Marker name (end of marker_status array if NULL) */
        int state; /* State (0 := marker disabled, 1 := marker enabled) */
-       char* fs; /* Format string (end of USTcmd_cmsf array if NULL) */
+       char *fs; /* Format string (end of marker_status array if NULL) */
 };
 
-pid_t* ustcmd_get_online_pids(void);
-int ustcmd_set_marker_state(const char*, int, pid_t);
-int ustcmd_destroy_trace(pid_t);
-int ustcmd_setup_and_start(pid_t);
-int ustcmd_stop_trace(pid_t);
-int ustcmd_start_trace(pid_t);
-int ustcmd_free_cmsf(struct USTcmd_cmsf*);
-unsigned int ustcmd_count_nl(const char*);
-int ustcmd_shoot(const char*, pid_t, char**);
-int ustcmd_get_cmsf(struct USTcmd_cmsf**, pid_t);
+extern pid_t *ustcmd_get_online_pids(void);
+extern int ustcmd_set_marker_state(const char *, int, pid_t);
+extern int ustcmd_destroy_trace(pid_t);
+extern int ustcmd_setup_and_start(pid_t);
+extern int ustcmd_stop_trace(pid_t);
+extern int ustcmd_start_trace(pid_t);
+extern int ustcmd_free_cmsf(struct marker_status *);
+extern unsigned int ustcmd_count_nl(const char *);
+extern int ustcmd_send_cmd(const char *, pid_t, char **);
+extern int ustcmd_get_cmsf(struct marker_status **, pid_t);
 
 #endif /* _USTCMD_H */
index e8199b3aaf5c6b70eadb2bd2fb01083684ae9c36..630f90609cb403ec136f8120edb8b85c171f99ee 100644 (file)
@@ -98,101 +98,47 @@ static int send_message_fd(int fd, const char *msg)
        }
 
        return 1;
-
-//     *reply = (char *) malloc(MSG_MAX+1);
-//     result = recv(fd, *reply, MSG_MAX, 0);
-//     if(result == -1) {
-//             PERROR("recv");
-//             return -1;
-//     }
-//     else if(result == 0) {
-//             return 0;
-//     }
-//     
-//     (*reply)[result] = '\0';
-//
-//     return 1;
 }
 
-static int send_message_path(const char *path, const char *msg, int signalpid)
-{
-       int fd;
-       int result;
-       struct sockaddr_un addr;
-
-       result = fd = socket(PF_UNIX, SOCK_STREAM, 0);
-       if(result == -1) {
-               PERROR("socket");
-               return -1;
-       }
-
-       addr.sun_family = AF_UNIX;
-
-       result = snprintf(addr.sun_path, UNIX_PATH_MAX, "%s", path);
-       if(result >= UNIX_PATH_MAX) {
-               ERR("string overflow allocating socket name");
-               return -1;
-       }
-
-       if(signalpid >= 0) {
-               result = signal_process(signalpid);
-               if(result == -1) {
-                       ERR("could not signal process");
-                       return -1;
-               }
-       }
-
-       result = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
-       if(result == -1) {
-               PERROR("connect");
-               return -1;
-       }
-
-       return send_message_fd(fd, msg);
-}
-
-///* pid: the pid of the trace process that must receive the msg
-//   msg: pointer to a null-terminated message to send
-//   reply: location where to put the null-terminated string of the reply;
-//       it must be free'd after usage
-// */
-//
-//int send_message_pid(pid_t pid, const char *msg, char **reply)
-//{
-//     int result;
-//     char path[UNIX_PATH_MAX];
-//
-//     result = snprintf(path, UNIX_PATH_MAX, "%s/%d", SOCK_DIR, pid);
-//     if(result >= UNIX_PATH_MAX) {
-//             fprintf(stderr, "string overflow allocating socket name");
-//             return -1;
-//     }
-//
-//     send_message_path(path, msg, reply, pid);
-//
-//     return 0;
-//}
-
 /* Called by an app to ask the consumer daemon to connect to it. */
 
 int ustcomm_request_consumer(pid_t pid, const char *channel)
 {
        char path[UNIX_PATH_MAX];
        int result;
-       char *msg;
+       char *msg=NULL;
+       int retval = 0;
+       struct ustcomm_connection conn;
 
        result = snprintf(path, UNIX_PATH_MAX, "%s/ustd", SOCK_DIR);
        if(result >= UNIX_PATH_MAX) {
-               fprintf(stderr, "string overflow allocating socket name");
+               ERR("string overflow allocating socket name");
                return -1;
        }
 
        asprintf(&msg, "collect %d %s", pid, channel); 
 
-       send_message_path(path, msg, -1);
+       /* don't signal it because it's the daemon */
+       result = ustcomm_connect_path(path, &conn, -1);
+       if(result == -1) {
+               WARN("ustcomm_connect_path failed");
+               retval = -1;
+               goto del_string;
+       }
+
+       result = ustcomm_send_request(&conn, msg, NULL);
+       if(result == -1) {
+               WARN("ustcomm_send_request failed");
+               retval = -1;
+               goto disconnect;
+       }
+
+       disconnect:
+       ustcomm_disconnect(&conn);
+       del_string:
        free(msg);
 
-       return 0;
+       return retval;
 }
 
 /* returns 1 to indicate a message was received
@@ -363,7 +309,7 @@ found:
        return src->fd;
 }
 
-static int init_named_socket(char *name, char **path_out)
+static int init_named_socket(const char *name, char **path_out)
 {
        int result;
        int fd;
@@ -445,7 +391,7 @@ int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char
        return 1;
 }
 
-int ustcomm_connect_path(char *path, struct ustcomm_connection *conn, pid_t signalpid)
+int ustcomm_connect_path(const char *path, struct ustcomm_connection *conn, pid_t signalpid)
 {
        int fd;
        int result;
@@ -497,18 +443,16 @@ int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn)
 
        result = snprintf(path, UNIX_PATH_MAX, "%s/%d", SOCK_DIR, pid);
        if(result >= UNIX_PATH_MAX) {
-               fprintf(stderr, "string overflow allocating socket name");
+               ERR("string overflow allocating socket name");
                return -1;
        }
 
        return ustcomm_connect_path(path, conn, pid);
 }
 
-int ustcomm_disconnect_app(struct ustcomm_connection *conn)
-{
-       close(conn->fd);
-       return 0;
-}
+/* Called by an application to initialize its server so daemons can
+ * connect to it.
+ */
 
 int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle)
 {
@@ -537,6 +481,10 @@ free_name:
        return -1;
 }
 
+/* Used by the daemon to initialize its server so applications
+ * can connect to it.
+ */
+
 int ustcomm_init_ustd(struct ustcomm_ustd *handle)
 {
        int result;
index 9dc84bdcc9cf1dacc3c868d22223b6df42f05bbb..83d8fae582d17be7e7090560547492cab2d5bdbc 100644 (file)
@@ -54,26 +54,28 @@ struct ustcomm_source {
        void *priv;
 };
 
-char *strdup_malloc(const char *s);
+extern char *strdup_malloc(const char *s);
 
 //int send_message_pid(pid_t pid, const char *msg, char **reply);
-int ustcomm_request_consumer(pid_t pid, const char *channel);
+extern int ustcomm_request_consumer(pid_t pid, const char *channel);
 
-int ustcomm_ustd_recv_message(struct ustcomm_ustd *ustd, char **msg, struct ustcomm_source *src, int timeout);
-int ustcomm_app_recv_message(struct ustcomm_app *app, char **msg, struct ustcomm_source *src, int timeout);
+extern int ustcomm_ustd_recv_message(struct ustcomm_ustd *ustd, char **msg, struct ustcomm_source *src, int timeout);
+extern int ustcomm_app_recv_message(struct ustcomm_app *app, char **msg, struct ustcomm_source *src, int timeout);
 
-int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle);
+extern int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle);
 
-int ustcomm_init_ustd(struct ustcomm_ustd *handle);
+extern int ustcomm_init_ustd(struct ustcomm_ustd *handle);
 
-int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn);
-int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply);
-int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src);
+extern int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn);
+extern int ustcomm_connect_path(const char *path, struct ustcomm_connection *conn, pid_t signalpid);
+extern int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply);
+extern int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src);
+extern int ustcomm_disconnect(struct ustcomm_connection *conn);
 
-int nth_token_is(char *str, char *token, int tok_no);
+extern int nth_token_is(char *str, char *token, int tok_no);
 
-char *nth_token(char *str, int tok_no);
+extern char *nth_token(char *str, int tok_no);
 
-int pid_is_online(pid_t);
+extern int pid_is_online(pid_t);
 
 #endif /* USTCOMM_H */
index b0c77e0972a66f8d03235494f4e5be72fcbc281a..2a8e0f253d1158e637d53f130eea3ca49de8b241 100644 (file)
@@ -162,18 +162,20 @@ static inline u64 trace_clock_read64(void)
        return retval | low;
 }
 
-//static inline u64 trace_clock_read64(void)
-//{
-//     struct timeval tv;
-//     u64 retval;
-//
-//     gettimeofday(&tv, NULL);
-//     retval = tv.tv_sec;
-//     retval *= 1000000;
-//     retval += tv.tv_usec;
-//
-//     return retval;
-//}
+#if 0
+static inline u64 trace_clock_read64(void)
+{
+       struct timeval tv;
+       u64 retval;
+
+       gettimeofday(&tv, NULL);
+       retval = tv.tv_sec;
+       retval *= 1000000;
+       retval += tv.tv_usec;
+
+       return retval;
+}
+#endif
 
 static inline u64 trace_clock_frequency(void)
 {
index 53ede09c39d78be21ddfb2f8209bd91415b112e5..d05674535dfbd5d4c9ecf3fdc0b5cb807ee4842d 100644 (file)
--- a/ust/ust.c
+++ b/ust/ust.c
@@ -42,7 +42,7 @@ enum command {
 struct ust_opts {
        enum command cmd;
        pid_t *pids;
-       charregex;
+       char *regex;
        regex_t preg;
        int regex_state;
 };
@@ -149,22 +149,32 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
                opts->pids = malloc((argc-optind+1) * sizeof(pid_t));
 
                for(i=optind; i<argc; i++) {
-                       opts->pids[pididx++] = atoi(argv[i]);
+                       /* don't take any chances, use a long long */
+                       long long tmp;
+                       char *endptr;
+                       tmp = strtoull(argv[i], &endptr, 10);
+                       if(*endptr != '\0') {
+                               ERR("The pid \"%s\" is invalid.", argv[i]);
+                               return 1;
+                       }
+                       opts->pids[pididx++] = (pid_t) tmp;
                }
                opts->pids[pididx] = -1;
        }
 
        if (opts->cmd == ENABLE_MARKER || opts->cmd == DISABLE_MARKER) {
-               if (opts->regex_state = regcomp(&opts->preg, opts->regex, 0)) {
-                       fprintf(stderr, "Invalid regular expression.\n");
+               opts->regex_state = regcomp(&opts->preg, opts->regex, 0);
+               if (opts->regex_state) {
+                       ERR("invalid regular expression\n");
                }
        }
 
        return 0;
 }
 
-static void regex_change_m_state(struct ust_opts* opts, pid_t pid) {
-       struct USTcmd_cmsf* cmsf = NULL;
+static void regex_change_m_state(struct ust_opts *opts, pid_t pid)
+{
+       struct marker_status *cmsf = NULL;
        unsigned int i = 0;
        int e = (opts->cmd == ENABLE_MARKER);
 
@@ -178,7 +188,7 @@ static void regex_change_m_state(struct ust_opts* opts, pid_t pid) {
                return;
        }
        while (cmsf[i].channel != NULL) {
-               charmc;
+               char *mc;
                asprintf(&mc, "%s/%s", cmsf[i].channel, cmsf[i].marker);
                if (regexec(&opts->preg, mc, 0, NULL, 0) == 0) {
                        /* We got a match! */
@@ -205,7 +215,6 @@ static void regex_change_m_state(struct ust_opts* opts, pid_t pid) {
 int main(int argc, char *argv[])
 {
        pid_t *pidit;
-       struct ustcomm_connection conn;
        int result;
        struct ust_opts opts;
 
@@ -219,6 +228,7 @@ int main(int argc, char *argv[])
 
        result = parse_opts_long(argc, argv, &opts);
        if(result) {
+               fprintf(stderr, "\n");
                usage();
                exit(EXIT_FAILURE);
        }
@@ -234,7 +244,7 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
        if (opts.cmd == GET_ONLINE_PIDS) {
-               pid_tpp = ustcmd_get_online_pids();
+               pid_t *pp = ustcmd_get_online_pids();
                unsigned int i = 0;
 
                if (pp) {
@@ -249,77 +259,67 @@ int main(int argc, char *argv[])
        }
 
        pidit = opts.pids;
-       struct USTcmd_cmsf* cmsf = NULL;
+       struct marker_status *cmsf = NULL;
 
        while(*pidit != -1) {
                switch (opts.cmd) {
                        case START_TRACE:
-                       if (ustcmd_start_trace(*pidit)) {
-                               fprintf(stderr,
-                                       "error while trying to for trace "
-                                       "with PID %u\n", (unsigned int) *pidit);
+                               result = ustcmd_start_trace(*pidit);
+                               if (result) {
+                                       ERR("error while trying to for trace with PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+                               //printf("sucessfully started trace for PID %u\n", (unsigned int) *pidit);
                                break;
-                       }
-                       printf("sucessfully started trace for PID %u\n",
-                               (unsigned int) *pidit);
-                       break;
 
                        case STOP_TRACE:
-                       if (ustcmd_stop_trace(*pidit)) {
-                               fprintf(stderr,
-                                       "error while trying to stop trace "
-                                       "for PID %u\n", (unsigned int) *pidit);
+                               result = ustcmd_stop_trace(*pidit);
+                               if (result) {
+                                       ERR("error while trying to stop trace for PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+                               //printf("sucessfully stopped trace for PID %u\n", (unsigned int) *pidit);
                                break;
-                       }
-                       printf("sucessfully stopped trace for PID %u\n",
-                               (unsigned int) *pidit);
-                       break;
 
                        case START:
-                       if (ustcmd_setup_and_start(*pidit)) {
-                               fprintf(stderr,
-                                       "error while trying to setup/start "
-                                       "trace for PID %u\n",
-                                       (unsigned int) *pidit);
+                               result = ustcmd_setup_and_start(*pidit);
+                               if (result) {
+                                       ERR("error while trying to setup/start trace for PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+                               //printf("sucessfully setup/started trace for PID %u\n", (unsigned int) *pidit);
                                break;
-                       }
-                       printf("sucessfully setup/started trace for PID %u\n",
-                               (unsigned int) *pidit);
-                       break;
 
                        case DESTROY:
-                       if (ustcmd_destroy_trace(*pidit)) {
-                               fprintf(stderr,
-                                       "error while trying to destroy "
-                                       "trace with PID %u\n",
-                                       (unsigned int) *pidit);
+                               result = ustcmd_destroy_trace(*pidit);
+                               if (result) {
+                                       ERR("error while trying to destroy trace with PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+                               //printf("sucessfully destroyed trace for PID %u\n", (unsigned int) *pidit);
                                break;
-                       }
-                       printf("sucessfully destroyed trace for PID %u\n",
-                               (unsigned int) *pidit);
-                       break;
 
                        case LIST_MARKERS:
-                       cmsf = NULL;
-                       if (ustcmd_get_cmsf(&cmsf, *pidit)) {
-                               fprintf(stderr,
-                                       "error while trying to list markers for"
-                                       " PID %u\n", (unsigned int) *pidit);
+                               cmsf = NULL;
+                               if (ustcmd_get_cmsf(&cmsf, *pidit)) {
+                                       fprintf(stderr,
+                                               "error while trying to list markers for"
+                                               " PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+                               unsigned int i = 0;
+                               while (cmsf[i].channel != NULL) {
+                                       printf("{PID: %u, channel/marker: %s/%s, "
+                                               "state: %u, fs: %s}\n",
+                                               (unsigned int) *pidit,
+                                               cmsf[i].channel,
+                                               cmsf[i].marker,
+                                               cmsf[i].state,
+                                               cmsf[i].fs);
+                                       ++i;
+                               }
+                               ustcmd_free_cmsf(cmsf);
                                break;
-                       }
-                       unsigned int i = 0;
-                       while (cmsf[i].channel != NULL) {
-                               printf("{PID: %u, channel/marker: %s/%s, "
-                                       "state: %u, fs: %s}\n",
-                                       (unsigned int) *pidit,
-                                       cmsf[i].channel,
-                                       cmsf[i].marker,
-                                       cmsf[i].state,
-                                       cmsf[i].fs);
-                               ++i;
-                       }
-                       ustcmd_free_cmsf(cmsf);
-                       break;
 
                        case ENABLE_MARKER:
                        case DISABLE_MARKER:
@@ -327,14 +327,13 @@ int main(int argc, char *argv[])
                        break;
 
                        default:
-                       fprintf(stderr, "error: unknown command...\n");
+                               ERR("unknown command\n");
                        break;
                }
 
                pidit++;
        }
 
-       exit_free:
        if (opts.pids != NULL) {
                free(opts.pids);
        }
This page took 0.037208 seconds and 4 git commands to generate.