From: Emil Velikov <emil.veli...@collabora.com>

The caller may ignore the return value (will be addressed with later
commit) so simply zero the count from the get-go. We're pretty much do
so, in all cases but one :-\

Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <l...@collabora.com>
Cc: Daniel Stone <dani...@collabora.com>
Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 glamor/glamor_egl.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index fab280ebf..3e1f45635 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -558,30 +558,26 @@ glamor_get_formats(ScreenPtr screen,
     struct glamor_egl_screen_private *glamor_egl;
     EGLint num;
 
+    /* Explicitly zero the count as the caller may ignore the return value */
+    *num_formats = 0;
+
     glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
 
     if (!glamor_egl->dmabuf_capable)
         return FALSE;
 
-    if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, 0, NULL, &num)) {
-        *num_formats = 0;
+    if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, 0, NULL, &num))
         return FALSE;
-    }
 
-    if (num == 0) {
-        *num_formats = 0;
+    if (num == 0)
         return TRUE;
-    }
 
     *formats = calloc(num, sizeof(CARD32));
-    if (*formats == NULL) {
-        *num_formats = 0;
+    if (*formats == NULL)
         return FALSE;
-    }
 
     if (!eglQueryDmaBufFormatsEXT(glamor_egl->display, num,
                                   (EGLint *) *formats, &num)) {
-        *num_formats = 0;
         free(*formats);
         return FALSE;
     }
-- 
2.16.0

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to