Fixed some compilation warning/error or error checking.
authorZhigang Gong <zhigang.gong@intel.com>
Tue, 19 Nov 2013 07:16:57 +0000 (15:16 +0800)
committerEric Anholt <eric@anholt.net>
Wed, 18 Dec 2013 19:23:54 +0000 (11:23 -0800)
There is one compilation error ,cast int to pointer, when built without
libgbm, reported by Gaetan Nadon.
And some error checking after memory allocation, reported by Seth Arnold.
There are still some similar issues in the largepixmap implementation.
They are relatively more complicate due to the heavy usage of RegionXXX
APIs which may allocate implicitly. Will fix them in the future.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Tested-by: Gaetan Nadon <memsize@videotron.ca>
glamor/glamor_core.c
glamor/glamor_egl.c

index 22065bc..eb1a08d 100644 (file)
@@ -68,11 +68,14 @@ glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
 
                dispatch->glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
                info = malloc(size);
-
-               dispatch->glGetShaderInfoLog(prog, size, NULL, info);
-               ErrorF("Failed to compile %s: %s\n",
-                      type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
-               ErrorF("Program source:\n%s", source);
+               if (info) {
+                       dispatch->glGetShaderInfoLog(prog, size, NULL, info);
+                       ErrorF("Failed to compile %s: %s\n",
+                              type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
+                       ErrorF("Program source:\n%s", source);
+                       free(info);
+               } else
+                       ErrorF("Failed to get shader compilation info.\n");
                FatalError("GLSL compile failure\n");
        }
 
index 50b764b..13b7f44 100644 (file)
@@ -500,6 +500,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 
        glamor_identify(0);
        glamor_egl = calloc(sizeof(*glamor_egl), 1);
+       if (glamor_egl == NULL)
+               return FALSE;
        if (xf86GlamorEGLPrivateIndex == -1)
                xf86GlamorEGLPrivateIndex =
                    xf86AllocateScrnInfoPrivateIndex();
@@ -514,7 +516,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
        }
        glamor_egl->display = eglGetDisplay(glamor_egl->gbm);
 #else
-       glamor_egl->display = eglGetDisplay((EGLNativeDisplayType)fd);
+       glamor_egl->display = eglGetDisplay((EGLNativeDisplayType)(intptr_t)fd);
 #endif
 
        glamor_egl->has_gem = glamor_egl_check_has_gem(fd);