* [ltt-dev] [UST PATCH] Set the exit status of ustctl main function
@ 2010-09-08 16:44 David Goulet
2010-09-08 16:49 ` David Goulet
2010-09-08 21:10 ` Mathieu Desnoyers
0 siblings, 2 replies; 5+ messages in thread
From: David Goulet @ 2010-09-08 16:44 UTC (permalink / raw)
Each possible command checks the return value and, on error,
print on stderr and set the retval. This makes ustctl return
an EXIT_FAILURE on any command that fails.
Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
ustctl/ustctl.c | 52 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c
index 152fc07..92e22cc 100644
--- a/ustctl/ustctl.c
+++ b/ustctl/ustctl.c
@@ -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);
+ retval = EXIT_FAILURE;
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);
+ retval = EXIT_FAILURE;
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);
+ retval = EXIT_FAILURE;
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);
+ retval = EXIT_FAILURE;
break;
}
break;
@@ -254,9 +258,7 @@ int main(int argc, char *argv[])
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;
}
@@ -275,26 +277,49 @@ int main(int argc, char *argv[])
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:
- 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:
- 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:
- 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);
+ retval = EXIT_FAILURE;
break;
}
@@ -305,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);
+ retval = EXIT_FAILURE;
break;
}
@@ -315,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);
- break;
+ retval = EXIT_FAILURE;
}
break;
@@ -323,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);
+ retval = EXIT_FAILURE;
break;
}
printf("the socket path is %s\n", tmp);
@@ -333,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);
+ retval = EXIT_FAILURE;
}
break;
@@ -340,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);
+ retval = EXIT_FAILURE;
}
break;
default:
ERR("unknown command\n");
- break;
+ retval = EXIT_FAILURE;
+ break;
}
pidit++;
--
1.7.2.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [ltt-dev] [UST PATCH] Set the exit status of ustctl main function
2010-09-08 16:44 [ltt-dev] [UST PATCH] Set the exit status of ustctl main function David Goulet
@ 2010-09-08 16:49 ` David Goulet
2010-09-08 21:14 ` Mathieu Desnoyers
2010-09-08 21:10 ` Mathieu Desnoyers
1 sibling, 1 reply; 5+ messages in thread
From: David Goulet @ 2010-09-08 16:49 UTC (permalink / raw)
Well following your reply Mathieu on error code, this patch need to be
modify to handle negative values.
Do you prefer doing that in a the next iteration with an "error code
handling" patch set ?
Thanks
David
On 10-09-08 12:44 PM, David Goulet wrote:
> Each possible command checks the return value and, on error,
> print on stderr and set the retval. This makes ustctl return
> an EXIT_FAILURE on any command that fails.
>
> Signed-off-by: David Goulet<david.goulet at polymtl.ca>
> ---
> ustctl/ustctl.c | 52 +++++++++++++++++++++++++++++++++++++++++-----------
> 1 files changed, 41 insertions(+), 11 deletions(-)
>
> diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c
> index 152fc07..92e22cc 100644
> --- a/ustctl/ustctl.c
> +++ b/ustctl/ustctl.c
> @@ -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);
> + retval = EXIT_FAILURE;
> 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);
> + retval = EXIT_FAILURE;
> 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);
> + retval = EXIT_FAILURE;
> 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);
> + retval = EXIT_FAILURE;
> break;
> }
> break;
> @@ -254,9 +258,7 @@ int main(int argc, char *argv[])
> 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;
> }
> @@ -275,26 +277,49 @@ int main(int argc, char *argv[])
> 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:
> - 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:
> - 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:
> - 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);
> + retval = EXIT_FAILURE;
> break;
> }
>
> @@ -305,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);
> + retval = EXIT_FAILURE;
> break;
> }
>
> @@ -315,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);
> - break;
> + retval = EXIT_FAILURE;
> }
> break;
>
> @@ -323,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);
> + retval = EXIT_FAILURE;
> break;
> }
> printf("the socket path is %s\n", tmp);
> @@ -333,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);
> + retval = EXIT_FAILURE;
> }
> break;
>
> @@ -340,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);
> + retval = EXIT_FAILURE;
> }
> break;
>
> default:
> ERR("unknown command\n");
> - break;
> + retval = EXIT_FAILURE;
> + break;
> }
>
> pidit++;
--
David Goulet
LTTng project, DORSAL Lab.
PGP/GPG : 1024D/16BD8563
BE3C 672B 9331 9796 291A 14C6 4AF7 C14B 16BD 8563
^ permalink raw reply [flat|nested] 5+ messages in thread* [ltt-dev] [UST PATCH] Set the exit status of ustctl main function
2010-09-08 16:49 ` David Goulet
@ 2010-09-08 21:14 ` Mathieu Desnoyers
0 siblings, 0 replies; 5+ messages in thread
From: Mathieu Desnoyers @ 2010-09-08 21:14 UTC (permalink / raw)
* David Goulet (david.goulet at polymtl.ca) wrote:
> Well following your reply Mathieu on error code, this patch need to be
> modify to handle negative values.
>
> Do you prefer doing that in a the next iteration with an "error code
> handling" patch set ?
Yes, please start by returning the failures from the program as a first
patch, and then change the error values in another patch. Note that the
program itself returns "EXIT_FAILURE", which value should not be
affected by the return values change.
Thanks,
Mathieu
>
> Thanks
> David
>
> On 10-09-08 12:44 PM, David Goulet wrote:
>> Each possible command checks the return value and, on error,
>> print on stderr and set the retval. This makes ustctl return
>> an EXIT_FAILURE on any command that fails.
>>
>> Signed-off-by: David Goulet<david.goulet at polymtl.ca>
>> ---
>> ustctl/ustctl.c | 52 +++++++++++++++++++++++++++++++++++++++++-----------
>> 1 files changed, 41 insertions(+), 11 deletions(-)
>>
>> diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c
>> index 152fc07..92e22cc 100644
>> --- a/ustctl/ustctl.c
>> +++ b/ustctl/ustctl.c
>> @@ -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);
>> + retval = EXIT_FAILURE;
>> 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);
>> + retval = EXIT_FAILURE;
>> 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);
>> + retval = EXIT_FAILURE;
>> 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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>> break;
>> @@ -254,9 +258,7 @@ int main(int argc, char *argv[])
>> 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;
>> }
>> @@ -275,26 +277,49 @@ int main(int argc, char *argv[])
>> 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:
>> - 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:
>> - 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:
>> - 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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>>
>> @@ -305,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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>>
>> @@ -315,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);
>> - break;
>> + retval = EXIT_FAILURE;
>> }
>> break;
>>
>> @@ -323,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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>> printf("the socket path is %s\n", tmp);
>> @@ -333,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);
>> + retval = EXIT_FAILURE;
>> }
>> break;
>>
>> @@ -340,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);
>> + retval = EXIT_FAILURE;
>> }
>> break;
>>
>> default:
>> ERR("unknown command\n");
>> - break;
>> + retval = EXIT_FAILURE;
>> + break;
>> }
>>
>> pidit++;
>
> --
> David Goulet
> LTTng project, DORSAL Lab.
>
> PGP/GPG : 1024D/16BD8563
> BE3C 672B 9331 9796 291A 14C6 4AF7 C14B 16BD 8563
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ltt-dev] [UST PATCH] Set the exit status of ustctl main function
2010-09-08 16:44 [ltt-dev] [UST PATCH] Set the exit status of ustctl main function David Goulet
2010-09-08 16:49 ` David Goulet
@ 2010-09-08 21:10 ` Mathieu Desnoyers
2010-09-09 2:47 ` David Goulet
1 sibling, 1 reply; 5+ messages in thread
From: Mathieu Desnoyers @ 2010-09-08 21:10 UTC (permalink / raw)
* David Goulet (david.goulet at polymtl.ca) wrote:
> Each possible command checks the return value and, on error,
> print on stderr and set the retval. This makes ustctl return
> an EXIT_FAILURE on any command that fails.
>
> Signed-off-by: David Goulet <david.goulet at polymtl.ca>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
> ustctl/ustctl.c | 52 +++++++++++++++++++++++++++++++++++++++++-----------
> 1 files changed, 41 insertions(+), 11 deletions(-)
>
> diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c
> index 152fc07..92e22cc 100644
> --- a/ustctl/ustctl.c
> +++ b/ustctl/ustctl.c
> @@ -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);
> + retval = EXIT_FAILURE;
> 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);
> + retval = EXIT_FAILURE;
> 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);
> + retval = EXIT_FAILURE;
> 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);
> + retval = EXIT_FAILURE;
> break;
> }
> break;
> @@ -254,9 +258,7 @@ int main(int argc, char *argv[])
> 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;
> }
> @@ -275,26 +277,49 @@ int main(int argc, char *argv[])
> 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:
> - 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:
> - 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:
> - 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);
> + retval = EXIT_FAILURE;
> break;
> }
>
> @@ -305,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);
> + retval = EXIT_FAILURE;
> break;
> }
>
> @@ -315,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);
> - break;
> + retval = EXIT_FAILURE;
> }
> break;
>
> @@ -323,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);
> + retval = EXIT_FAILURE;
> break;
> }
> printf("the socket path is %s\n", tmp);
> @@ -333,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);
> + retval = EXIT_FAILURE;
> }
> break;
>
> @@ -340,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);
> + retval = EXIT_FAILURE;
> }
> break;
>
> default:
> ERR("unknown command\n");
> - break;
> + retval = EXIT_FAILURE;
> + break;
> }
>
> pidit++;
> --
> 1.7.2.3
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 5+ messages in thread* [ltt-dev] [UST PATCH] Set the exit status of ustctl main function
2010-09-08 21:10 ` Mathieu Desnoyers
@ 2010-09-09 2:47 ` David Goulet
0 siblings, 0 replies; 5+ messages in thread
From: David Goulet @ 2010-09-09 2:47 UTC (permalink / raw)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Don't commit this patch now. I'll submit a version 2 with the standard syntax.
The if clause I added have no space. Better to do it right then later ;)
I just had a flash about that...!
Cheers
David
On 10-09-08 05:10 PM, Mathieu Desnoyers wrote:
> * David Goulet (david.goulet at polymtl.ca) wrote:
>> Each possible command checks the return value and, on error,
>> print on stderr and set the retval. This makes ustctl return
>> an EXIT_FAILURE on any command that fails.
>>
>> Signed-off-by: David Goulet <david.goulet at polymtl.ca>
>
> Acked-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> ---
>> ustctl/ustctl.c | 52 +++++++++++++++++++++++++++++++++++++++++-----------
>> 1 files changed, 41 insertions(+), 11 deletions(-)
>>
>> diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c
>> index 152fc07..92e22cc 100644
>> --- a/ustctl/ustctl.c
>> +++ b/ustctl/ustctl.c
>> @@ -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);
>> + retval = EXIT_FAILURE;
>> 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);
>> + retval = EXIT_FAILURE;
>> 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);
>> + retval = EXIT_FAILURE;
>> 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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>> break;
>> @@ -254,9 +258,7 @@ int main(int argc, char *argv[])
>> 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;
>> }
>> @@ -275,26 +277,49 @@ int main(int argc, char *argv[])
>> 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:
>> - 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:
>> - 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:
>> - 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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>>
>> @@ -305,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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>>
>> @@ -315,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);
>> - break;
>> + retval = EXIT_FAILURE;
>> }
>> break;
>>
>> @@ -323,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);
>> + retval = EXIT_FAILURE;
>> break;
>> }
>> printf("the socket path is %s\n", tmp);
>> @@ -333,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);
>> + retval = EXIT_FAILURE;
>> }
>> break;
>>
>> @@ -340,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);
>> + retval = EXIT_FAILURE;
>> }
>> break;
>>
>> default:
>> ERR("unknown command\n");
>> - break;
>> + retval = EXIT_FAILURE;
>> + break;
>> }
>>
>> pidit++;
>> --
>> 1.7.2.3
>>
>>
>> _______________________________________________
>> ltt-dev mailing list
>> ltt-dev at lists.casi.polymtl.ca
>> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>>
>
- --
David Goulet
LTTng project, DORSAL Lab.
1024D/16BD8563
BE3C 672B 9331 9796 291A 14C6 4AF7 C14B 16BD 8563
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAkyISs0ACgkQSvfBSxa9hWN/nQCeMFUarLyy0EU9s7Et7vRQuyv2
q4EAnjy4cmohw6UNe1uUy8MOtWKRiNKA
=IdRU
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-09-09 2:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-08 16:44 [ltt-dev] [UST PATCH] Set the exit status of ustctl main function David Goulet
2010-09-08 16:49 ` David Goulet
2010-09-08 21:14 ` Mathieu Desnoyers
2010-09-08 21:10 ` Mathieu Desnoyers
2010-09-09 2:47 ` David Goulet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox