[PATCH xserver 2/3] modesetting: Check for -1 before converting to unsigned int.

msrb at suse.com msrb at suse.com
Mon Mar 27 12:03:38 UTC 2017


From: Michal Srb <msrb at suse.com>

dri2.c:516:21: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
    if (front->name < 0)

Prevents a failure from being ignored.
---
 hw/xfree86/drivers/modesetting/dri2.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 8944ef1..a9e20b1 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -511,11 +511,14 @@ update_front(DrawablePtr draw, DRI2BufferPtr front)
     ms_dri2_buffer_private_ptr priv = front->driverPrivate;
     CARD32 size;
     CARD16 pitch;
+    int name;
 
-    front->name = glamor_name_from_pixmap(pixmap, &pitch, &size);
-    if (front->name < 0)
+    name = glamor_name_from_pixmap(pixmap, &pitch, &size);
+    if (name < 0)
         return FALSE;
 
+    front->name = name;
+
     (*screen->DestroyPixmap) (priv->pixmap);
     front->pitch = pixmap->devKind;
     front->cpp = pixmap->drawable.bitsPerPixel / 8;
-- 
2.10.2



More information about the xorg-devel mailing list