projects
/
ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set the exit status of ustctl main function v3
[ust.git]
/
ustctl
/
ustctl.c
diff --git
a/ustctl/ustctl.c
b/ustctl/ustctl.c
index b9f2dce83b43913bc6aaedd766d160d9a81accdb..35bea7ae6b3d84f17c1493e378593149f4b6e90c 100644
(file)
--- a/
ustctl/ustctl.c
+++ b/
ustctl/ustctl.c
@@
-22,8
+22,7
@@
#include <stdlib.h>
#include <fcntl.h>
#include <stdlib.h>
#include <fcntl.h>
-#include "ustcomm.h"
-#include "ustcmd.h"
+#include "ust/ustcmd.h"
#include "usterr.h"
enum command {
#include "usterr.h"
enum command {
@@
-148,7
+147,7
@@
int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
if (argc - optind > 0 && opts->cmd != GET_ONLINE_PIDS) {
int i;
int pididx=0;
if (argc - optind > 0 && opts->cmd != GET_ONLINE_PIDS) {
int i;
int pididx=0;
- opts->pids = malloc((argc-optind+1) * sizeof(pid_t));
+ opts->pids =
z
malloc((argc-optind+1) * sizeof(pid_t));
for(i=optind; i<argc; i++) {
/* don't take any chances, use a long long */
for(i=optind; i<argc; i++) {
/* don't take any chances, use a long long */
@@
-171,6
+170,7
@@
int main(int argc, char *argv[])
{
pid_t *pidit;
int result;
{
pid_t *pidit;
int result;
+ int retval = EXIT_SUCCESS;
char *tmp;
struct ust_opts opts;
char *tmp;
struct ust_opts opts;
@@
-223,6
+223,7
@@
int main(int argc, char *argv[])
result = ustcmd_create_trace(*pidit);
if (result) {
ERR("error while trying to create trace with PID %u\n", (unsigned int) *pidit);
result = ustcmd_create_trace(*pidit);
if (result) {
ERR("error while trying to create trace with PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-231,6
+232,7
@@
int main(int argc, char *argv[])
result = ustcmd_start_trace(*pidit);
if (result) {
ERR("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);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-239,6
+241,7
@@
int main(int argc, char *argv[])
result = ustcmd_stop_trace(*pidit);
if (result) {
ERR("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);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-247,6
+250,7
@@
int main(int argc, char *argv[])
result = ustcmd_destroy_trace(*pidit);
if (result) {
ERR("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);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-254,9
+258,8
@@
int main(int argc, char *argv[])
case LIST_MARKERS:
cmsf = NULL;
if (ustcmd_get_cmsf(&cmsf, *pidit)) {
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);
+ ERR("error while trying to list markers for PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
unsigned int i = 0;
break;
}
unsigned int i = 0;
@@
-274,26
+277,49
@@
int main(int argc, char *argv[])
break;
case ENABLE_MARKER:
break;
case ENABLE_MARKER:
- if(opts.regex)
- ustcmd_set_marker_state(opts.regex, 1, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_marker_state(opts.regex, 1, *pidit)) {
+ ERR("error while trying to enable marker %s with PID %u\n",
+ opts.regex, (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
break;
case DISABLE_MARKER:
break;
case DISABLE_MARKER:
- if(opts.regex)
- ustcmd_set_marker_state(opts.regex, 0, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_marker_state(opts.regex, 0, *pidit)) {
+ ERR("error while trying to disable marker %s with PID %u\n",
+ opts.regex, (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
break;
case SET_SUBBUF_SIZE:
break;
case SET_SUBBUF_SIZE:
- ustcmd_set_subbuf_size(opts.regex, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_subbuf_size(opts.regex, *pidit)) {
+ ERR("error while trying to set the size of subbuffers with PID %u\n",
+ (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
break;
case SET_SUBBUF_NUM:
break;
case SET_SUBBUF_NUM:
- ustcmd_set_subbuf_num(opts.regex, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_subbuf_num(opts.regex, *pidit)) {
+ ERR("error while trying to set the number of subbuffers with PID %u\n",
+ (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
break;
case GET_SUBBUF_SIZE:
result = ustcmd_get_subbuf_size(opts.regex, *pidit);
if (result == -1) {
ERR("error while trying to get_subuf_size with PID %u\n", (unsigned int) *pidit);
break;
case GET_SUBBUF_SIZE:
result = ustcmd_get_subbuf_size(opts.regex, *pidit);
if (result == -1) {
ERR("error while trying to get_subuf_size with PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
}
@@
-304,6
+330,7
@@
int main(int argc, char *argv[])
result = ustcmd_get_subbuf_num(opts.regex, *pidit);
if (result == -1) {
ERR("error while trying to get_subuf_num with PID %u\n", (unsigned int) *pidit);
result = ustcmd_get_subbuf_num(opts.regex, *pidit);
if (result == -1) {
ERR("error while trying to get_subuf_num with PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
}
@@
-314,7
+341,7
@@
int main(int argc, char *argv[])
result = ustcmd_alloc_trace(*pidit);
if (result) {
ERR("error while trying to alloc trace with PID %u\n", (unsigned int) *pidit);
result = ustcmd_alloc_trace(*pidit);
if (result) {
ERR("error while trying to alloc trace with PID %u\n", (unsigned int) *pidit);
-
break
;
+
retval = EXIT_FAILURE
;
}
break;
}
break;
@@
-322,6
+349,7
@@
int main(int argc, char *argv[])
result = ustcmd_get_sock_path(&tmp, *pidit);
if (result) {
ERR("error while trying to get sock path for PID %u\n", (unsigned int) *pidit);
result = ustcmd_get_sock_path(&tmp, *pidit);
if (result) {
ERR("error while trying to get sock path for PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
printf("the socket path is %s\n", tmp);
break;
}
printf("the socket path is %s\n", tmp);
@@
-332,6
+360,7
@@
int main(int argc, char *argv[])
result = ustcmd_set_sock_path(opts.regex, *pidit);
if (result) {
ERR("error while trying to set sock path for PID %u\n", (unsigned int) *pidit);
result = ustcmd_set_sock_path(opts.regex, *pidit);
if (result) {
ERR("error while trying to set sock path for PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
}
break;
}
break;
@@
-339,12
+368,14
@@
int main(int argc, char *argv[])
result = ustcmd_force_switch(*pidit);
if (result) {
ERR("error while trying to force switch for PID %u\n", (unsigned int) *pidit);
result = ustcmd_force_switch(*pidit);
if (result) {
ERR("error while trying to force switch for PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
}
break;
default:
ERR("unknown command\n");
}
break;
default:
ERR("unknown command\n");
- break;
+ retval = EXIT_FAILURE;
+ break;
}
pidit++;
}
pidit++;
@@
-357,6
+388,6
@@
int main(int argc, char *argv[])
free(opts.regex);
}
free(opts.regex);
}
- return
0
;
+ return
retval
;
}
}
This page took
0.024921 seconds
and
4
git commands to generate.