Mesa (master): sw/xlib: Fix bad logic in shm allocation.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Sat Apr 24 09:16:12 UTC 2010


Module: Mesa
Branch: master
Commit: 94b04d3d1ccd1b717dbc9d797341f1170121645a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=94b04d3d1ccd1b717dbc9d797341f1170121645a

Author: José Fonseca <jfonseca at vmware.com>
Date:   Sat Apr 24 10:15:09 2010 +0100

sw/xlib: Fix bad logic in shm allocation.

Fixes fdo 27823.

---

 src/gallium/winsys/sw/xlib/xlib_sw_winsys.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
index 7df7416..56d2df8 100644
--- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
+++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
@@ -124,6 +124,9 @@ static char *alloc_shm(struct xm_displaytarget *buf, unsigned size)
 {
    XShmSegmentInfo *const shminfo = & buf->shminfo;
 
+   shminfo->shmid = -1;
+   shminfo->shmaddr = (char *) -1;
+
    shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
    if (shminfo->shmid < 0) {
       return NULL;
@@ -385,12 +388,9 @@ xm_displaytarget_create(struct sw_winsys *winsys,
    xm_dt->stride = align(util_format_get_stride(format, width), alignment);
    size = xm_dt->stride * nblocksy;
 
-   if (!debug_get_option_xlib_no_shm())
-   {
+   if (!debug_get_option_xlib_no_shm()) {
       xm_dt->data = alloc_shm(xm_dt, size);
-      if(!xm_dt->data) {
-         xm_dt->shminfo.shmid = -1;
-         xm_dt->shminfo.shmaddr = (char *) -1;
+      if (xm_dt->data) {
          xm_dt->shm = TRUE;
       }
    }




More information about the mesa-commit mailing list