From 5769e2edab302b05b8b1811bbb22ce14b032315f Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Fri, 8 Nov 2019 15:00:57 +0000 Subject: [PATCH] graphics: Avoid -Wtype-limits for comparing unsigned enum >= 0 SrtWindowSystem has no valid negative values, so the compiler can use an unsigned base type for it, which makes window_system >= 0 tautologous. SrtRenderingInterface has the same issue. Use an unsigned cast to make the assertion obviously equally valid, whether the enum's base type is signed or not. Signed-off-by: Simon McVittie <smcv@collabora.com> --- steam-runtime-tools/graphics.c | 6 ++---- steam-runtime-tools/system-info.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/steam-runtime-tools/graphics.c b/steam-runtime-tools/graphics.c index 3d2b9933a..718f5b4a7 100644 --- a/steam-runtime-tools/graphics.c +++ b/steam-runtime-tools/graphics.c @@ -683,10 +683,8 @@ _srt_check_graphics (const char *helpers_path, gboolean parse_wflinfo = (rendering_interface != SRT_RENDERING_INTERFACE_VULKAN); g_return_val_if_fail (details_out == NULL || *details_out == NULL, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (window_system >= 0, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (window_system < SRT_N_WINDOW_SYSTEMS, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (rendering_interface >= 0, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (rendering_interface < SRT_N_RENDERING_INTERFACES, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + g_return_val_if_fail (((unsigned) window_system) < SRT_N_WINDOW_SYSTEMS, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + g_return_val_if_fail (((unsigned) rendering_interface) < SRT_N_RENDERING_INTERFACES, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); g_return_val_if_fail (_srt_check_not_setuid (), SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); GPtrArray *argv = _argv_for_graphics_test (helpers_path, diff --git a/steam-runtime-tools/system-info.c b/steam-runtime-tools/system-info.c index 2f73fc669..ae2144d21 100644 --- a/steam-runtime-tools/system-info.c +++ b/steam-runtime-tools/system-info.c @@ -1371,10 +1371,8 @@ srt_system_info_check_graphics (SrtSystemInfo *self, g_return_val_if_fail (multiarch_tuple != NULL, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); g_return_val_if_fail (details_out == NULL || *details_out == NULL, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (window_system >= 0, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (window_system < SRT_N_WINDOW_SYSTEMS, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (rendering_interface >= 0, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); - g_return_val_if_fail (rendering_interface < SRT_N_RENDERING_INTERFACES, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + g_return_val_if_fail (((unsigned) window_system) < SRT_N_WINDOW_SYSTEMS, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + g_return_val_if_fail (((unsigned) rendering_interface) < SRT_N_RENDERING_INTERFACES, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); abi = ensure_abi (self, multiarch_tuple); -- GitLab