[igt-dev] [PATCH i-g-t] benchmarks/gem_wsim: Avoid labs(unsigned long)

Ville Syrjala ville.syrjala at linux.intel.com
Wed Feb 12 17:17:32 UTC 2020


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

../benchmarks/gem_wsim.c: In function ‘calibrate_nop’:
../benchmarks/gem_wsim.c:2999:4: warning: taking the absolute value of unsigned type ‘long unsigned int’ has no effect [-Wabsolute-value]
 2999 |    labs(size - last_size) > (size * tolerance_pct / 100));

Frankly the warning looks like nonsense to me, unless the compiler
actually optimizes the labs() away. Otherwise there's going to be an
implicit cast to signed long anyway since that's what labs() takes.
But the warning is easy enough to avoid here so let's do it.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 benchmarks/gem_wsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 0ef1cf28f76f..aaf3a16198df 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -2969,7 +2969,7 @@ static unsigned long calibrate_nop(unsigned int tolerance_pct, struct intel_exec
 		.buffers_ptr = (uintptr_t)&obj,
 		.flags = engine->flags
 	};
-	unsigned long size, last_size;
+	long size, last_size;
 	struct timespec t_0, t_end;
 
 	clock_gettime(CLOCK_MONOTONIC, &t_0);
-- 
2.24.1



More information about the igt-dev mailing list