From de3423e98e82fb39ea4860bbb42a1e21d1b7fb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 30 Apr 2019 14:33:47 +0200 Subject: [PATCH] vkd3d-shader: Improve asserts for write mask component count. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Helps Clang Static Analyzer. Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/vkd3d_shader_private.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 73ba93fe..54d07050 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -883,13 +883,14 @@ static inline unsigned int vkd3d_write_mask_get_component_idx(DWORD write_mask) static inline unsigned int vkd3d_write_mask_component_count(DWORD write_mask) { - assert(write_mask); - return vkd3d_popcount(write_mask & VKD3DSP_WRITEMASK_ALL); + unsigned int count = vkd3d_popcount(write_mask & VKD3DSP_WRITEMASK_ALL); + assert(1 <= count && count <= VKD3D_VEC4_SIZE); + return count; } static inline unsigned int vkd3d_write_mask_from_component_count(unsigned int component_count) { - assert(component_count <= 4); + assert(component_count <= VKD3D_VEC4_SIZE); return (VKD3DSP_WRITEMASK_0 << component_count) - 1; }