[PATCH] util: constant -1 with expression of type char

yskelg@gmail.com posted 1 patch 1 year, 7 months ago
tools/perf/util/evsel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] util: constant -1 with expression of type char
Posted by yskelg@gmail.com 1 year, 7 months ago
From: Yunseong Kim <yskelg@gmail.com>

This patch resolve following warning.

tools/perf/util/evsel.c:1620:9: error: result of comparison of constant
-1 with expression of type 'char' is always false
 -Werror,-Wtautological-constant-out-of-range-compare
 1620 |                 if (c == -1)
      |                     ~ ^  ~~

Signed-off-by: Yunseong Kim <yskelg@gmail.com>
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 25857894c047..bc603193c477 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1620,7 +1620,7 @@ static int evsel__read_group(struct evsel *leader, int cpu_map_idx, int thread)
 
 static bool read_until_char(struct io *io, char e)
 {
-	char c;
+	int c;
 
 	do {
 		c = io__get_char(io);
-- 
2.45.2
Re: [PATCH] util: constant -1 with expression of type char
Posted by Namhyung Kim 1 year, 7 months ago
On Thu, 20 Jun 2024 05:34:29 +0900, yskelg@gmail.com wrote:

> This patch resolve following warning.
> 
> tools/perf/util/evsel.c:1620:9: error: result of comparison of constant
> -1 with expression of type 'char' is always false
>  -Werror,-Wtautological-constant-out-of-range-compare
>  1620 |                 if (c == -1)
>       |                     ~ ^  ~~
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung