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.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I6ce97c2481f36573d1a221b59e2459f1fe35ded9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1761
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
- if (ctx->ec->log_level != -1) {
+ if (ctx->ec->is_log_level_set) {
bt_event_class_set_log_level(ir_ec, ctx->ec->log_level);
}
bt_event_class_set_log_level(ir_ec, ctx->ec->log_level);
}
GString *emf_uri;
bt_event_class_log_level log_level;
bool is_translated;
GString *emf_uri;
bt_event_class_log_level log_level;
bool is_translated;
/* Owned by this */
struct ctf_field_class *spec_context_fc;
/* Owned by this */
struct ctf_field_class *spec_context_fc;
BT_ASSERT(ec->name);
ec->emf_uri = g_string_new(NULL);
BT_ASSERT(ec->emf_uri);
BT_ASSERT(ec->name);
ec->emf_uri = g_string_new(NULL);
BT_ASSERT(ec->emf_uri);
+ ec->is_log_level_set = false;
+static inline
+void ctf_event_class_set_log_level(struct ctf_event_class *ec,
+ enum bt_event_class_log_level log_level)
+{
+ BT_ASSERT(ec);
+ ec->log_level = log_level;
+ ec->is_log_level_set = true;
+}
+
static inline
void ctf_event_class_destroy(struct ctf_event_class *ec)
{
static inline
void ctf_event_class_destroy(struct ctf_event_class *ec)
{
_SET(set, _EVENT_FIELDS_SET);
} else if (strcmp(left, "loglevel") == 0) {
uint64_t loglevel_value;
_SET(set, _EVENT_FIELDS_SET);
} else if (strcmp(left, "loglevel") == 0) {
uint64_t loglevel_value;
+ bool is_log_level_known = true;
bt_event_class_log_level log_level = -1;
if (_IS_SET(set, _EVENT_LOG_LEVEL_SET)) {
bt_event_class_log_level log_level = -1;
if (_IS_SET(set, _EVENT_LOG_LEVEL_SET)) {
log_level = BT_EVENT_CLASS_LOG_LEVEL_DEBUG;
break;
default:
log_level = BT_EVENT_CLASS_LOG_LEVEL_DEBUG;
break;
default:
+ is_log_level_known = false;
_BT_COMP_LOGW_NODE(node, "Not setting event class's log level because its value is unknown: "
"log-level=%" PRIu64, loglevel_value);
}
_BT_COMP_LOGW_NODE(node, "Not setting event class's log level because its value is unknown: "
"log-level=%" PRIu64, loglevel_value);
}
- if (log_level != -1) {
- event_class->log_level = log_level;
+ if (is_log_level_known) {
+ ctf_event_class_set_log_level(event_class, log_level);
}
_SET(set, _EVENT_LOG_LEVEL_SET);
}
_SET(set, _EVENT_LOG_LEVEL_SET);