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: I5dcbaa2066cbab8c429ff54e8d8b8b295fc8baf1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1764
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
* classes for which the common boundary is not the boundary of
* a byte cannot have different byte orders.
*
* classes for which the common boundary is not the boundary of
* a byte cannot have different byte orders.
*
- * This is set to -1 on reset and when the last basic field class
- * was a string class.
+ * This is set to CTF_BYTE_ORDER_UNKNOWN on reset and when the last
+ * basic field class was a string class.
*/
enum ctf_byte_order last_bo;
*/
enum ctf_byte_order last_bo;
}
/* Always valid if last byte order is unknown */
}
/* Always valid if last byte order is unknown */
- if (bfcr->last_bo == -1) {
+ if (bfcr->last_bo == CTF_BYTE_ORDER_UNKNOWN) {
goto end;
}
/* Always valid if next byte order is unknown */
goto end;
}
/* Always valid if next byte order is unknown */
+ if (next_bo == CTF_BYTE_ORDER_UNKNOWN) {
stack_clear(bfcr->stack);
stitch_reset(bfcr);
bfcr->buf.addr = NULL;
stack_clear(bfcr->stack);
stitch_reset(bfcr);
bfcr->buf.addr = NULL;
+ bfcr->last_bo = CTF_BYTE_ORDER_UNKNOWN;
+ CTF_BYTE_ORDER_UNKNOWN,
CTF_BYTE_ORDER_DEFAULT,
CTF_BYTE_ORDER_LITTLE,
CTF_BYTE_ORDER_BIG,
CTF_BYTE_ORDER_DEFAULT,
CTF_BYTE_ORDER_LITTLE,
CTF_BYTE_ORDER_BIG,
struct ctf_trace_class *tc = g_new0(struct ctf_trace_class, 1);
BT_ASSERT(tc);
struct ctf_trace_class *tc = g_new0(struct ctf_trace_class, 1);
BT_ASSERT(tc);
- tc->default_byte_order = -1;
+ tc->default_byte_order = CTF_BYTE_ORDER_UNKNOWN;
tc->clock_classes = g_ptr_array_new_with_free_func(
(GDestroyNotify) ctf_clock_class_destroy);
BT_ASSERT(tc->clock_classes);
tc->clock_classes = g_ptr_array_new_with_free_func(
(GDestroyNotify) ctf_clock_class_destroy);
BT_ASSERT(tc->clock_classes);
struct ctf_node *unary_expr)
{
const char *str;
struct ctf_node *unary_expr)
{
const char *str;
- enum ctf_byte_order bo = -1;
+ enum ctf_byte_order bo = CTF_BYTE_ORDER_UNKNOWN;
if (unary_expr->u.unary_expression.type != UNARY_STRING) {
_BT_COMP_LOGE_NODE(unary_expr,
if (unary_expr->u.unary_expression.type != UNARY_STRING) {
_BT_COMP_LOGE_NODE(unary_expr,
}
byte_order = get_real_byte_order(ctx, right);
}
byte_order = get_real_byte_order(ctx, right);
- if (byte_order == -1) {
+ if (byte_order == CTF_BYTE_ORDER_UNKNOWN) {
_BT_COMP_LOGE_NODE(right,
"Invalid `byte_order` attribute in integer field class: "
"ret=%d", ret);
_BT_COMP_LOGE_NODE(right,
"Invalid `byte_order` attribute in integer field class: "
"ret=%d", ret);
}
byte_order = get_real_byte_order(ctx, right);
}
byte_order = get_real_byte_order(ctx, right);
- if (byte_order == -1) {
+ if (byte_order == CTF_BYTE_ORDER_UNKNOWN) {
_BT_COMP_LOGE_NODE(right,
"Invalid `byte_order` attribute in floating point number field class: "
"ret=%d", ret);
_BT_COMP_LOGE_NODE(right,
"Invalid `byte_order` attribute in floating point number field class: "
"ret=%d", ret);
- BT_ASSERT(ctx->ctf_tc->default_byte_order != -1);
+ BT_ASSERT(ctx->ctf_tc->default_byte_order != CTF_BYTE_ORDER_UNKNOWN);
_SET(set, _TRACE_BYTE_ORDER_SET);
} else if (strcmp(left, "packet.header") == 0) {
if (_IS_SET(set, _TRACE_PACKET_HEADER_SET)) {
_SET(set, _TRACE_BYTE_ORDER_SET);
} else if (strcmp(left, "packet.header") == 0) {
if (_IS_SET(set, _TRACE_PACKET_HEADER_SET)) {
struct ctf_node, siblings);
bo = byte_order_from_unary_expr(ctx,
right_node);
struct ctf_node, siblings);
bo = byte_order_from_unary_expr(ctx,
right_node);
+ if (bo == CTF_BYTE_ORDER_UNKNOWN) {
_BT_COMP_LOGE_NODE(node,
"Invalid `byte_order` attribute in trace (`trace` block): "
"expecting `le`, `be`, or `network`.");
_BT_COMP_LOGE_NODE(node,
"Invalid `byte_order` attribute in trace (`trace` block): "
"expecting `le`, `be`, or `network`.");
* have the native byte order yet, and we don't have any
* trace block yet, then fail with EINCOMPLETE.
*/
* have the native byte order yet, and we don't have any
* trace block yet, then fail with EINCOMPLETE.
*/
- if (ctx->ctf_tc->default_byte_order == -1) {
+ if (ctx->ctf_tc->default_byte_order == CTF_BYTE_ORDER_UNKNOWN) {
bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
if (got_trace_decl) {
_BT_COMP_LOGE_NODE(node,
bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
if (got_trace_decl) {
_BT_COMP_LOGE_NODE(node,