OSDN Git Service

Fix pointer-to-int and int-to-pointer warnings.
authorDan Albert <danalbert@google.com>
Mon, 23 Feb 2015 18:39:14 +0000 (10:39 -0800)
committerDan Albert <danalbert@google.com>
Mon, 23 Feb 2015 18:45:27 +0000 (10:45 -0800)
Change-Id: If534cbcf2c3e644270572cbf829ba9b5acab29e6

opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp
opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp
opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp

index 003efd3..2abc916 100755 (executable)
@@ -14,7 +14,8 @@ static jobject
 android_eglGetDisplayInt
   (JNIEnv *_env, jobject _this, jint display_id) {
 
-    if ((EGLNativeDisplayType)display_id != EGL_DEFAULT_DISPLAY) {
+    if (static_cast<uintptr_t>(display_id) !=
+        reinterpret_cast<uintptr_t>(EGL_DEFAULT_DISPLAY)) {
         jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglGetDisplay");
         return 0;
     }
index 41df486..d844152 100644 (file)
@@ -32,7 +32,7 @@ android_glDrawElementsInstanced__IIIII
         (GLenum)mode,
         (GLsizei)count,
         (GLenum)type,
-        (GLvoid *)indicesOffset,
+        (GLvoid *)static_cast<uintptr_t>(indicesOffset),
         (GLsizei)instanceCount
     );
 }
index 0514fe9..a977693 100644 (file)
@@ -157,7 +157,11 @@ android_glGetTransformFeedbackVarying__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuff
         (GLsizei *)length,
         (GLint *)size,
         (GLenum *)type,
-        (char *)name
+        // The cast below is incorrect. The driver will end up writing to the
+        // address specified by name, which will always crash the process since
+        // it is guaranteed to be in low memory. The additional static_cast
+        // suppresses the warning for now. http://b/19478262
+        (char *)static_cast<uintptr_t>(name)
     );
     if (_typeArray) {
         releasePointer(_env, _typeArray, type, JNI_TRUE);