vulkan/wsi/x11: Smplify implementation of vkGetPhysicalDeviceSurfaceFormatsKHR
authorEduardo Lima Mitev <elima@igalia.com>
Fri, 28 Oct 2016 12:45:36 +0000 (14:45 +0200)
committerEduardo Lima Mitev <elima@igalia.com>
Fri, 28 Oct 2016 14:53:28 +0000 (16:53 +0200)
This patch simplifies x11_surface_get_formats(). It is actually just a
readability improvement over the patch I provided earlier this week
(750d8cad72).

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
src/vulkan/wsi/wsi_common_x11.c

index 4a232f5213b43664719976ee5805161ea2dd73ca..814284799f61a5aeaf032f925bb3fb58c11b4936 100644 (file)
@@ -396,16 +396,11 @@ x11_surface_get_formats(VkIcdSurfaceBase *surface,
       return VK_SUCCESS;
    }
 
-   VkResult result = VK_SUCCESS;
-
-   if (*pSurfaceFormatCount > ARRAY_SIZE(formats))
-      *pSurfaceFormatCount = ARRAY_SIZE(formats);
-   else if (*pSurfaceFormatCount < ARRAY_SIZE(formats))
-      result = VK_INCOMPLETE;
-
+   *pSurfaceFormatCount = MIN2(*pSurfaceFormatCount, ARRAY_SIZE(formats));
    typed_memcpy(pSurfaceFormats, formats, *pSurfaceFormatCount);
 
-   return result;
+   return *pSurfaceFormatCount < ARRAY_SIZE(formats) ?
+      VK_INCOMPLETE : VK_SUCCESS;
 }
 
 static VkResult