[gtk/test-coverage: 7/8] glshader: Add preconditions
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/test-coverage: 7/8] glshader: Add preconditions
- Date: Fri, 15 Jul 2022 19:47:37 +0000 (UTC)
commit a4c6517d069d8d5e72fcf66ee37b6d863cd52b56
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jul 15 14:40:55 2022 -0400
glshader: Add preconditions
Add preconditions to many of the glshader
uniform apis.
gsk/gskglshader.c | 7 +++++++
1 file changed, 7 insertions(+)
---
diff --git a/gsk/gskglshader.c b/gsk/gskglshader.c
index 7823651b8b..b8d5566d29 100644
--- a/gsk/gskglshader.c
+++ b/gsk/gskglshader.c
@@ -162,6 +162,7 @@ uniform_type_from_glsl (const char *str)
return GSK_GL_UNIFORM_TYPE_NONE;
}
+#ifdef G_ENABLE_DEBUG
static const char *
uniform_type_name (GskGLUniformType type)
{
@@ -194,6 +195,7 @@ uniform_type_name (GskGLUniformType type)
return NULL;
}
}
+#endif
static int
uniform_type_size (GskGLUniformType type)
@@ -397,6 +399,7 @@ gsk_gl_shader_constructed (GObject *object)
shader->n_textures = max_texture_seen;
+#ifdef G_ENABLE_DEBUG
if (GSK_DEBUG_CHECK(SHADERS))
{
GString *s;
@@ -414,6 +417,7 @@ gsk_gl_shader_constructed (GObject *object)
s->str);
g_string_free (s, TRUE);
}
+#endif
}
#define SPACE_RE "[ \\t]+" // Don't use \s, we don't want to match newlines
@@ -631,6 +635,7 @@ gsk_gl_shader_get_uniform_name (GskGLShader *shader,
int idx)
{
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), NULL);
+ g_return_val_if_fail (0 <= idx && idx < shader->uniforms->len, NULL);
return g_array_index (shader->uniforms, GskGLUniform, idx).name;
}
@@ -675,6 +680,7 @@ gsk_gl_shader_get_uniform_type (GskGLShader *shader,
int idx)
{
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), 0);
+ g_return_val_if_fail (0 <= idx && idx < shader->uniforms->len, 0);
return g_array_index (shader->uniforms, GskGLUniform, idx).type;
}
@@ -693,6 +699,7 @@ gsk_gl_shader_get_uniform_offset (GskGLShader *shader,
int idx)
{
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), 0);
+ g_return_val_if_fail (0 <= idx && idx < shader->uniforms->len, 0);
return g_array_index (shader->uniforms, GskGLUniform, idx).offset;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]