summaryrefslogtreecommitdiff
path: root/tests/texturing/max-texture-size.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2014-02-02 01:20:41 -0800
committerKenneth Graunke <kenneth@whitecape.org>2014-02-05 15:31:12 -0800
commit299c77675983876e3aefbc55dd43100bd0250fee (patch)
tree5f4c18d5415a750a7565c3b866d29e2f75806ca6 /tests/texturing/max-texture-size.c
parenteb0f1e9f521b2dd8ccea6e6f3bf46f3fff6103d2 (diff)
max-texture-size: Use "goto out" to avoid duplicating clean up code.
In general, "goto" should be avoided. One commonly accepted use is to jump to the bottom of the function before returning, so all the necessary clean up code/memory freeing can be done in one place. This avoids even more duplication in the next patch. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'tests/texturing/max-texture-size.c')
-rw-r--r--tests/texturing/max-texture-size.c59
1 files changed, 24 insertions, 35 deletions
diff --git a/tests/texturing/max-texture-size.c b/tests/texturing/max-texture-size.c
index 24d2122ce..a95def537 100644
--- a/tests/texturing/max-texture-size.c
+++ b/tests/texturing/max-texture-size.c
@@ -231,6 +231,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
GLfloat *pixels = NULL;
GLenum err = GL_NO_ERROR;
GLboolean first_oom;
+ bool success = false;
/* Query the largest supported texture size */
glGetIntegerv(getMaxTarget(target), &maxSide);
@@ -257,9 +258,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
first_oom = err == GL_OUT_OF_MEMORY;
/* Report a GL error other than GL_OUT_OF_MEMORY */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
- free(pixels);
- printf("Unexpected GL error: 0x%x\n", err);
- return false;
+ goto out;
}
glTexSubImage1D(target, 0, 0, maxSide/2, GL_RGBA,
@@ -270,9 +269,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
* INVALID_VALUE */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
(!first_oom || err != GL_INVALID_VALUE)) {
- free(pixels);
- printf("Unexpected GL error: 0x%x\n", err);
- return false;
+ goto out;
}
break;
@@ -284,9 +281,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
first_oom = err == GL_OUT_OF_MEMORY;
/* Report a GL error other than GL_OUT_OF_MEMORY */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
- free(pixels);
- printf("Unexpected GL error: 0x%x\n", err);
- return false;
+ goto out;
}
glTexSubImage2D(target, 0, 0, 0, maxSide/2, maxSide/2,
@@ -297,9 +292,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
* INVALID_VALUE */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
(!first_oom || err != GL_INVALID_VALUE)) {
- free(pixels);
- printf("Unexpected GL error: 0x%x\n", err);
- return false;
+ goto out;
}
break;
@@ -310,9 +303,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
err = glGetError();
/* Report a GL error other than GL_OUT_OF_MEMORY */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
- printf("Unexpected GL error: 0x%x\n", err);
- free(pixels);
- return false;
+ goto out;
}
break;
@@ -325,9 +316,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
first_oom = err == GL_OUT_OF_MEMORY;
/* Report a GL error other than GL_OUT_OF_MEMORY */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
- printf("Unexpected GL error: 0x%x\n", err);
- free(pixels);
- return false;
+ goto out;
}
glTexSubImage3D(target, 0, 0, 0, 0, maxSide/2,
@@ -338,9 +327,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
* INVALID_VALUE */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
(!first_oom || err != GL_INVALID_VALUE)) {
- free(pixels);
- printf("Unexpected GL error: 0x%x\n", err);
- return false;
+ goto out;
}
break;
@@ -355,11 +342,8 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
err = glGetError();
first_oom = first_oom || err == GL_OUT_OF_MEMORY;
/* Report a GL error other than GL_OUT_OF_MEMORY */
- if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
- printf("Unexpected GL error: 0x%x\n", err);
- free(pixels);
- return false;
- }
+ if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY)
+ goto out;
}
for (k = 0; k < 6; k++) {
@@ -370,25 +354,30 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
err = glGetError();
if (err == GL_OUT_OF_MEMORY) {
- free(pixels);
- return true;
+ success = true;
+ goto out;
}
/* Report a GL error other than GL_OUT_OF_MEMORY and
* INVALID_VALUE */
if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
(!first_oom || err != GL_INVALID_VALUE)) {
- printf("Unexpected GL error: 0x%x\n", err);
- free(pixels);
- return false;
+ goto out;
}
}
break;
}
- if (pixels)
- free(pixels);
- /* If execution reaches this point, return true */
- return true;
+
+ /* Apparently we succeeded. */
+ success = true;
+
+out:
+ if (!success)
+ printf("Unexpected GL error: 0x%x\n", err);
+
+ free(pixels);
+ return success;
+
}
static bool