From 74a4e3ea85714c95b67c301cd06df7a78b59d832 Mon Sep 17 00:00:00 2001 From: Pyry Haulos Date: Tue, 7 Apr 2015 10:02:37 -0700 Subject: [PATCH] Fix unintialized memory issues reported by valgrind Change-Id: I2cdd303e0035d8e599fe5f4d9520f58c3058ccf4 --- framework/randomshaders/rsgExpression.cpp | 1 + .../functional/es31fNegativeStateApiTests.cpp | 38 +++++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/framework/randomshaders/rsgExpression.cpp b/framework/randomshaders/rsgExpression.cpp index bc3b6a5..b0184d9 100644 --- a/framework/randomshaders/rsgExpression.cpp +++ b/framework/randomshaders/rsgExpression.cpp @@ -523,6 +523,7 @@ inline DstType convert (SrcType src) // According to GLSL ES spec. template <> inline bool convert (float src) { return src != 0.0f; } template <> inline bool convert (int src) { return src != 0; } +template <> inline bool convert (bool src) { return src; } template <> inline float convert (bool src) { return src ? 1.0f : 0.0f; } template <> inline int convert (bool src) { return src ? 1 : 0; } diff --git a/modules/gles31/functional/es31fNegativeStateApiTests.cpp b/modules/gles31/functional/es31fNegativeStateApiTests.cpp index 1fe9b6b..cedbe0b 100644 --- a/modules/gles31/functional/es31fNegativeStateApiTests.cpp +++ b/modules/gles31/functional/es31fNegativeStateApiTests.cpp @@ -118,8 +118,8 @@ void get_integer64v (NegativeTestContext& ctx) void get_integeri_v (NegativeTestContext& ctx) { - GLint data = -1; - GLint maxUniformBufferBindings; + GLint data = -1; + GLint maxUniformBufferBindings = 0; ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value."); ctx.glGetIntegeri_v(-1, 0, &data); @@ -136,8 +136,8 @@ void get_integeri_v (NegativeTestContext& ctx) void get_integer64i_v (NegativeTestContext& ctx) { - GLint64 data = (GLint64)-1;; - GLint maxUniformBufferBindings; + GLint64 data = (GLint64)-1; + GLint maxUniformBufferBindings = 0; ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value."); ctx.glGetInteger64i_v(-1, 0, &data); @@ -162,7 +162,7 @@ void get_string (NegativeTestContext& ctx) void get_stringi (NegativeTestContext& ctx) { - GLint numExtensions; + GLint numExtensions = 0; ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value."); ctx.glGetStringi(-1, 0); @@ -180,10 +180,10 @@ void get_stringi (NegativeTestContext& ctx) void get_attached_shaders (NegativeTestContext& ctx) { - GLuint shaders[1]; + GLuint shaders[1] = { 0 }; GLuint shaderObject = ctx.glCreateShader(GL_VERTEX_SHADER); GLuint program = ctx.glCreateProgram(); - GLsizei count[1]; + GLsizei count[1] = { 0 }; ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); ctx.glGetAttachedShaders(-1, 1, &count[0], &shaders[0]); @@ -283,10 +283,10 @@ void get_shader_precision_format (NegativeTestContext& ctx) void get_shader_source (NegativeTestContext& ctx) { - GLsizei length[1]; - char source[1]; - GLuint program = ctx.glCreateProgram(); - GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); + GLsizei length[1] = { 0 }; + char source[1] = { 0 }; + GLuint program = ctx.glCreateProgram(); + GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); ctx.glGetShaderSource(-1, 1, &length[0], &source[0]); @@ -311,9 +311,9 @@ void get_shader_source (NegativeTestContext& ctx) void get_programiv (NegativeTestContext& ctx) { - GLuint program = ctx.glCreateProgram(); - GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); - GLint params[1] = { -1 }; + GLuint program = ctx.glCreateProgram(); + GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); + GLint params[1] = { 0 }; ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); ctx.glGetProgramiv(program, -1, ¶ms[0]); @@ -364,7 +364,7 @@ void get_program_info_log (NegativeTestContext& ctx) void get_tex_parameterfv (NegativeTestContext& ctx) { - GLfloat params[1]; + GLfloat params[1] = { 0 }; ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value."); ctx.glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]); @@ -378,7 +378,7 @@ void get_tex_parameterfv (NegativeTestContext& ctx) void get_tex_parameteriv (NegativeTestContext& ctx) { - GLint params[1]; + GLint params[1] = { 0 }; ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value."); ctx.glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]); @@ -401,7 +401,7 @@ void get_uniformfv (NegativeTestContext& ctx) GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); GLuint programEmpty = ctx.glCreateProgram(); - GLfloat params[4]; + GLfloat params[4] = { 0.f }; ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); ctx.glGetUniformfv (-1, unif, ¶ms[0]); @@ -438,7 +438,7 @@ void get_uniformiv (NegativeTestContext& ctx) GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); GLuint programEmpty = ctx.glCreateProgram(); - GLint params[4]; + GLint params[4] = { 0 }; ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); ctx.glGetUniformiv (-1, unif, ¶ms[0]); @@ -475,7 +475,7 @@ void get_uniformuiv (NegativeTestContext& ctx) GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); GLuint programEmpty = ctx.glCreateProgram(); - GLuint params[4]; + GLuint params[4] = { 0 }; ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); ctx.glGetUniformuiv (-1, unif, ¶ms[0]); -- 2.7.4