[Glamor] [PATCH] Fixed some compilation warning/error or error checking.

zhigang.gong at linux.intel.com zhigang.gong at linux.intel.com
Mon Nov 18 23:16:57 PST 2013


From: Zhigang Gong <zhigang.gong at intel.com>

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 at intel.com>
---
 src/glamor_core.c |   13 ++++++++-----
 src/glamor_egl.c  |    4 +++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/glamor_core.c b/src/glamor_core.c
index 22065bc..eb1a08d 100644
--- a/src/glamor_core.c
+++ b/src/glamor_core.c
@@ -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");
 	}
 
diff --git a/src/glamor_egl.c b/src/glamor_egl.c
index cd0bdc0..7abad77 100644
--- a/src/glamor_egl.c
+++ b/src/glamor_egl.c
@@ -466,6 +466,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();
@@ -480,7 +482,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);
-- 
1.7.9.5



More information about the Glamor mailing list