[Piglit] [PATCH 2/3] util/waffle: Refactor make_context_current()
Chad Versace
chad.versace at linux.intel.com
Wed Feb 20 15:03:18 PST 2013
This refactor makes the function body more readable.
Understanding the function no longer requires the reader to track the
value of `ok` throughout the function body. Also, some conditional
branches have been removed by using early returns.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
.../piglit-framework-gl/piglit_wfl_framework.c | 37 ++++++++++------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/tests/util/piglit-framework-gl/piglit_wfl_framework.c b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
index 172c610..77a491b 100644
--- a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
@@ -347,14 +347,13 @@ make_context_current(struct piglit_wfl_framework *wfl_fw,
ok = make_context_current_singlepass(wfl_fw, test_config,
CONTEXT_GL_CORE,
partial_config_attrib_list);
- if (ok) {
+ if (ok)
return;
- } else {
- printf("piglit: info: Failed to create GL %d.%d "
- "core context\n",
- test_config->supports_gl_core_version / 10,
- test_config->supports_gl_core_version % 10);
- }
+
+ printf("piglit: info: Failed to create GL %d.%d "
+ "core context\n",
+ test_config->supports_gl_core_version / 10,
+ test_config->supports_gl_core_version % 10);
}
if (test_config->supports_gl_core_version &&
@@ -370,14 +369,13 @@ make_context_current(struct piglit_wfl_framework *wfl_fw,
ok = make_context_current_singlepass(wfl_fw, test_config,
CONTEXT_GL_COMPAT,
partial_config_attrib_list);
- if (ok) {
- return;
- } else {
- printf("piglit: info: Failed to create GL %d.%d "
- "compatibility context\n",
- test_config->supports_gl_compat_version / 10,
- test_config->supports_gl_compat_version % 10);
- }
+ if (ok)
+ return;
+
+ printf("piglit: info: Failed to create GL %d.%d "
+ "compatibility context\n",
+ test_config->supports_gl_compat_version / 10,
+ test_config->supports_gl_compat_version % 10);
}
#elif defined(PIGLIT_USE_OPENGL_ES1) || \
@@ -389,17 +387,14 @@ make_context_current(struct piglit_wfl_framework *wfl_fw,
if (ok)
return;
- else
- printf("piglit: info: Failed to create GL ES context\n");
+ printf("piglit: info: Failed to create GL ES context\n");
#else
# error
#endif
- if (!ok) {
- printf("piglit: info: Failed to create any GL context\n");
- piglit_report_result(PIGLIT_SKIP);
- }
+ printf("piglit: info: Failed to create any GL context\n");
+ piglit_report_result(PIGLIT_SKIP);
}
--
1.8.1.1
More information about the Piglit
mailing list