Fix: lttng_set_event_filter() was returning bad error code
authorDavid Goulet <dgoulet@efficios.com>
Mon, 24 Sep 2012 17:24:48 +0000 (13:24 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 24 Sep 2012 17:24:48 +0000 (13:24 -0400)
Change the API call to return a lttng-error.h code. Also change the
already enable filter message from an ERR() to a WARN().

On error, the lttng UI now prints the returned error from the API call.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng/commands/enable_events.c
src/lib/lttng-ctl/lttng-ctl.c

index 9a4b9aac90c50753b62524404a487dd0578c61cf..0bd96eb303680cc715dced1bda4eb845d74c75eb 100644 (file)
@@ -422,10 +422,13 @@ static int enable_events(char *session_name)
                        if (ret < 0) {
                                switch (-ret) {
                                case LTTNG_ERR_FILTER_EXIST:
-                                       ERR("Filter on events is already enabled"
+                                       WARN("Filter on events is already enabled"
                                                        " (channel %s, session %s)",
                                                channel_name, session_name);
                                        break;
+                               case LTTNG_ERR_FILTER_INVAL:
+                               case LTTNG_ERR_FILTER_NOMEM:
+                                       ERR("%s", lttng_strerror(ret));
                                default:
                                        ERR("Setting filter: '%s'", opt_filter);
                                        /*
@@ -579,10 +582,13 @@ static int enable_events(char *session_name)
                        if (ret < 0) {
                                switch (-ret) {
                                case LTTNG_ERR_FILTER_EXIST:
-                                       ERR("Filter on event %s is already enabled"
+                                       WARN("Filter on event %s is already enabled"
                                                        " (channel %s, session %s)",
                                                event_name, channel_name, session_name);
                                        break;
+                               case LTTNG_ERR_FILTER_INVAL:
+                               case LTTNG_ERR_FILTER_NOMEM:
+                                       ERR("%s", lttng_strerror(ret));
                                default:
                                        ERR("Setting filter for event %s: '%s'", ev.name,
                                                        opt_filter);
index 27d69089fa7faf615626be99cff64ad136f41769..e4560bb7fb927895d5b11fd84db2338001b0507b 100644 (file)
@@ -782,24 +782,24 @@ int lttng_set_event_filter(struct lttng_handle *handle,
                        strlen(filter_expression), "r");
        if (!fmem) {
                fprintf(stderr, "Error opening memory as stream\n");
-               return -ENOMEM;
+               return -LTTNG_ERR_FILTER_NOMEM;
        }
        ctx = filter_parser_ctx_alloc(fmem);
        if (!ctx) {
                fprintf(stderr, "Error allocating parser\n");
-               ret = -ENOMEM;
+               ret = -LTTNG_ERR_FILTER_NOMEM;
                goto alloc_error;
        }
        ret = filter_parser_ctx_append_ast(ctx);
        if (ret) {
                fprintf(stderr, "Parse error\n");
-               ret = -EINVAL;
+               ret = -LTTNG_ERR_FILTER_INVAL;
                goto parse_error;
        }
        ret = filter_visitor_set_parent(ctx);
        if (ret) {
                fprintf(stderr, "Set parent error\n");
-               ret = -EINVAL;
+               ret = -LTTNG_ERR_FILTER_INVAL;
                goto parse_error;
        }
        if (print_xml) {
@@ -807,7 +807,7 @@ int lttng_set_event_filter(struct lttng_handle *handle,
                if (ret) {
                        fflush(stdout);
                        fprintf(stderr, "XML print error\n");
-                       ret = -EINVAL;
+                       ret = -LTTNG_ERR_FILTER_INVAL;
                        goto parse_error;
                }
        }
@@ -817,7 +817,7 @@ int lttng_set_event_filter(struct lttng_handle *handle,
        ret = filter_visitor_ir_generate(ctx);
        if (ret) {
                fprintf(stderr, "Generate IR error\n");
-               ret = -EINVAL;
+               ret = -LTTNG_ERR_FILTER_INVAL;
                goto parse_error;
        }
        dbg_printf("done\n");
@@ -826,7 +826,7 @@ int lttng_set_event_filter(struct lttng_handle *handle,
        fflush(stdout);
        ret = filter_visitor_ir_check_binary_op_nesting(ctx);
        if (ret) {
-               ret = -EINVAL;
+               ret = -LTTNG_ERR_FILTER_INVAL;
                goto parse_error;
        }
        dbg_printf("done\n");
@@ -836,7 +836,7 @@ int lttng_set_event_filter(struct lttng_handle *handle,
        ret = filter_visitor_bytecode_generate(ctx);
        if (ret) {
                fprintf(stderr, "Generate bytecode error\n");
-               ret = -EINVAL;
+               ret = -LTTNG_ERR_FILTER_INVAL;
                goto parse_error;
        }
        dbg_printf("done\n");
This page took 0.030203 seconds and 4 git commands to generate.