From fa38ef4e237dcdde1bf6b2cb6437099ce147415a Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 3 Feb 2019 17:26:42 +0000 Subject: [PATCH] Add a macro to validate a vendor value --- daemon/gamemode-gpu.c | 3 +-- daemon/gpu-query.h | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/gamemode-gpu.c b/daemon/gamemode-gpu.c index d865a1d..53229ad 100644 --- a/daemon/gamemode-gpu.c +++ b/daemon/gamemode-gpu.c @@ -92,8 +92,7 @@ int game_mode_initialise_gpu(GameModeConfig *config, GameModeGPUInfo **info) } /* verify GPU vendor */ - if (!(new_info->vendor == Vendor_NVIDIA || new_info->vendor == Vendor_AMD || - new_info->vendor == Vendor_Intel)) { + if (!GPUVendorValid(new_info->vendor)) { LOG_ERROR( "ERROR: Invalid gpu_vendor value (0x%04x) set in configuration, will not apply " "optimisations!\n", diff --git a/daemon/gpu-query.h b/daemon/gpu-query.h index 4116888..77f2d86 100644 --- a/daemon/gpu-query.h +++ b/daemon/gpu-query.h @@ -39,6 +39,9 @@ enum GPUVendor { Vendor_Intel = 0x8086 }; +#define GPUVendorValid(vendor) \ + (vendor == Vendor_NVIDIA || vendor == Vendor_AMD || vendor == Vendor_Intel) + /* Storage for GPU info*/ struct GameModeGPUInfo { long vendor;