src.ctf.lttng-live: Use SESSION_NOT_FOUND_ACTION_UNKNOWN in place of -1
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 23 Jul 2019 19:55:12 +0000 (15:55 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 29 Jul 2019 14:46:25 +0000 (10:46 -0400)
Seen on clang-3.9, 4.0 and clang-1001.0.46.4.

  Comparison of constant -1 with expression of type 'enum *****'
  is always false [-Wtautological-constant-out-of-range-compare]

Note that the enum underlying type is implementation defined and left to
the choice of the compiler by the standard [1] (6.7.2.2 4). Most
compiler default to unsigned int. The use of -1 is not a problem per see
since wrap around of unsigned int behaviour is not undefined. Using -1
is the equivalent of assigning UINT_MAX here. This warning was removed
for later clang for these specific cases since the effect of always being
false is erroneous.

Still, it make more sense to use a specific enum for such case instead
of relying on the compiler type.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I447d04333ae104ea953437b095053f341f87bbb7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1763
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/lttng-live.h

index 62dc28f0d8b4ebfe28e06a585362c1271d6ad2c8..5946f064bd8b0b04a5ec8d542de625a3f64fea59 100644 (file)
@@ -1372,6 +1372,17 @@ bt_component_class_message_iterator_init_method_status lttng_live_msg_iter_init(
                                SESS_NOT_FOUND_ACTION_END_STR,
                                lttng_live->params.url->str);
                        break;
+               case SESSION_NOT_FOUND_ACTION_UNKNOWN:
+               default:
+                       /* Fallthrough */
+                       BT_COMP_LOGE("Unknown action for session not found"
+                               "error. Fail the message iterator"
+                               "initialization because of %s=\"%s\" "
+                               "component parameter: url =\"%s\"",
+                               SESS_NOT_FOUND_ACTION_PARAM,
+                               SESS_NOT_FOUND_ACTION_FAIL_STR,
+                               lttng_live->params.url->str);
+                       break;
                }
        }
 
@@ -1505,7 +1516,7 @@ enum session_not_found_action parse_session_not_found_action_param(
        } else if (strcmp(no_session_act_str, SESS_NOT_FOUND_ACTION_END_STR) == 0) {
                action = SESSION_NOT_FOUND_ACTION_END;
        } else {
-               action = -1;
+               action = SESSION_NOT_FOUND_ACTION_UNKNOWN;
        }
 
        return action;
@@ -1545,7 +1556,7 @@ struct lttng_live_component *lttng_live_component_create(const bt_value *params,
        if (value && bt_value_is_string(value)) {
                lttng_live->params.sess_not_found_act =
                        parse_session_not_found_action_param(value);
-               if (lttng_live->params.sess_not_found_act == -1) {
+               if (lttng_live->params.sess_not_found_act == SESSION_NOT_FOUND_ACTION_UNKNOWN) {
                        BT_COMP_LOGE("Unexpected value for `%s` parameter: "
                                "value=\"%s\"", SESS_NOT_FOUND_ACTION_PARAM,
                                bt_value_string_get(value));
index 3ae12082830a55cf0ff1dd2b64611f85239f3d50..e5d08613d560192bfb2584684521a0dfcaa9a3fe 100644 (file)
@@ -187,6 +187,7 @@ struct lttng_live_session {
 };
 
 enum session_not_found_action {
+       SESSION_NOT_FOUND_ACTION_UNKNOWN,
        SESSION_NOT_FOUND_ACTION_CONTINUE,
        SESSION_NOT_FOUND_ACTION_FAIL,
        SESSION_NOT_FOUND_ACTION_END,
This page took 0.026191 seconds and 4 git commands to generate.