From ed82693b973205b1b8b1d0577c0f788cef1a5f44 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Fri, 17 Jan 2020 17:41:51 +0000 Subject: [PATCH] system-info: Make SRT_DRIVER_FLAGS_NONE the absence of flags GLib flags conventionally have a NONE value that is numerically zero and represents default behaviour, with any deviation from default behaviour being represented by a nonzero flag. In particular, for the flags we currently know (INCLUDE_ALL and NONE), there are only two states that make sense to have numerically distinct: NONE and INCLUDE_ALL. If NONE is non-zero, then 0 makes no sense (it would request behaviour that differs from the behaviour of not setting any flags, but what would that mean?), while NONE|INCLUDE_ALL logically ought to be equivalent to INCLUDE_ALL. Fixing this requires some adjustments to the logic for skipping extra drivers, because (NONE & flags) will never be nonzero. It's the presence or absence of INCLUDE_ALL that we should care about, not the presence or absence of NONE. Signed-off-by: Simon McVittie <smcv@collabora.com> --- steam-runtime-tools/system-info.c | 7 +++++-- steam-runtime-tools/system-info.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/steam-runtime-tools/system-info.c b/steam-runtime-tools/system-info.c index c61f71b6e..c0b51bf30 100644 --- a/steam-runtime-tools/system-info.c +++ b/steam-runtime-tools/system-info.c @@ -2529,8 +2529,10 @@ srt_system_info_list_dri_drivers (SrtSystemInfo *self, for (iter = abi->cached_dri_list; iter != NULL; iter = iter->next) { - if ((flags & SRT_DRIVER_FLAGS_NONE) && srt_dri_driver_is_extra (iter->data)) + if ((flags & SRT_DRIVER_FLAGS_INCLUDE_ALL) == 0 && + srt_dri_driver_is_extra (iter->data)) continue; + ret = g_list_prepend (ret, g_object_ref (iter->data)); } @@ -2584,7 +2586,8 @@ srt_system_info_list_va_api_drivers (SrtSystemInfo *self, for (iter = abi->cached_va_api_list; iter != NULL; iter = iter->next) { - if ((flags & SRT_DRIVER_FLAGS_NONE) && srt_va_api_driver_is_extra (iter->data)) + if ((flags & SRT_DRIVER_FLAGS_INCLUDE_ALL) == 0 && + srt_va_api_driver_is_extra (iter->data)) continue; ret = g_list_prepend (ret, g_object_ref (iter->data)); } diff --git a/steam-runtime-tools/system-info.h b/steam-runtime-tools/system-info.h index 9ae6ef71d..d44c9b600 100644 --- a/steam-runtime-tools/system-info.h +++ b/steam-runtime-tools/system-info.h @@ -68,7 +68,7 @@ typedef enum typedef enum { SRT_DRIVER_FLAGS_INCLUDE_ALL = (1 << 1), - SRT_DRIVER_FLAGS_NONE = (1 << 0) + SRT_DRIVER_FLAGS_NONE = 0 } SrtDriverFlags; typedef struct _SrtSystemInfo SrtSystemInfo; -- GitLab