[lttng-dev] [PATCH lttng-tools] Fix: clang 'constant-out-of-range-compare' warning

Zifei Tong zifeitong at gmail.com
Tue Mar 4 08:27:38 EST 2014


This patch fixes two 'autological-constant-out-of-range-compare'
clang warnings caused by comparing enum type variables with -1.

It's possible that compilers optimize these two comparisons away.

Signed-off-by: Zifei Tong <zifeitong at gmail.com>
---
 src/bin/lttng/commands/add_context.c     | 2 +-
 src/bin/lttng/commands/enable_channels.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c
index 3cd00f3..6483c98 100644
--- a/src/bin/lttng/commands/add_context.c
+++ b/src/bin/lttng/commands/add_context.c
@@ -474,7 +474,7 @@ int cmd_add_context(int argc, const char **argv)
 			}
 
 			type->opt = &ctx_opts[index];
-			if (type->opt->ctx_type == -1) {
+			if (type->opt->symbol == NULL) {
 				ERR("Unknown context type %s", opt_type);
 				free(type);
 				ret = CMD_ERROR;
diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c
index c4bbc11..55fbae6 100644
--- a/src/bin/lttng/commands/enable_channels.c
+++ b/src/bin/lttng/commands/enable_channels.c
@@ -169,7 +169,7 @@ static void set_default_attr(struct lttng_domain *dom)
 	if (chan.attr.read_timer_interval == -1) {
 		chan.attr.read_timer_interval = default_attr.read_timer_interval;
 	}
-	if (chan.attr.output == -1) {
+	if ((int) chan.attr.output == -1) {
 		chan.attr.output = default_attr.output;
 	}
 	if (chan.attr.tracefile_count == -1) {
-- 
1.9.0




More information about the lttng-dev mailing list