[PATCH i-g-t] tests/intel/drm_fdinfo: Fix type comparison warning

Marcin Bernatowicz marcin.bernatowicz at linux.intel.com
Fri Aug 2 10:51:20 UTC 2024


Resolve a compilation warning caused by comparing distinct pointer
types without a cast in the max macro usage.

Cc: Matt Roper <matthew.d.roper at intel.com>
Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Fixes: dd461382e7fa ("tests/intel: Apply igt.cocci transforms")
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz at linux.intel.com>

---
../lib/igt_aux.h:229:35: warning: comparison of distinct pointer types
lacks a cast
  229 |         (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
      |                                   ^~
../lib/igt_aux.h:246:3: note: in expansion of macro ‘__typecheck’
  246 |  (__typecheck(x, y) && __no_side_effects(x, y))
      |   ^~~~~~~~~~~
../lib/igt_aux.h:249:24: note: in expansion of macro ‘__safe_cmp’
  249 |  __builtin_choose_expr(__safe_cmp(x, y), \
      |                        ^~~~~~~~~~
../lib/igt_aux.h:254:19: note: in expansion of macro ‘__careful_cmp’
  254 | #define max(x, y) __careful_cmp(x, y, >, max)
      |                   ^~~~~~~~~~~~~
../tests/intel/drm_fdinfo.c:808:9: note: in expansion of macro ‘max’
  808 |  return max(count, 0U);

 tests/intel/drm_fdinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/intel/drm_fdinfo.c b/tests/intel/drm_fdinfo.c
index 160dc3d0a..43216a64e 100644
--- a/tests/intel/drm_fdinfo.c
+++ b/tests/intel/drm_fdinfo.c
@@ -805,7 +805,7 @@ static size_t read_fdinfo(char *buf, const size_t sz, int at, const char *name)
 		buf[count - 1] = 0;
 	close(fd);
 
-	return max(count, 0);
+	return max_t(typeof(count), count, 0);
 }
 
 /*
-- 
2.31.1



More information about the igt-dev mailing list