[waffle] [PATCH 29/29] tests/gl_basic: call waffle_error_get_code() less often

Emil Velikov emil.l.velikov at gmail.com
Wed Jan 6 13:27:55 PST 2016


From: Emil Velikov <emil.velikov at collabora.com>

There is no need to (potentially) call the function twice in a roll, as
there are no waffle calls inbetween that can trigger a change.

Use a switch (as opposed to if-else 'spaghetti'), which has the
benefit of slightly improved readability.

While we're here, fix the copy/paste in the related comment.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 tests/functional/gl_basic_test.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 10a7af8..02d4712 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -320,15 +320,14 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ args)
         assert_true(waffle_error_get_code() == expect_error);
         return;
     } else if (ts->config == NULL) {
-        if (waffle_error_get_code() == WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM) {
-            skip();
-        }
-        else if (waffle_error_get_code() == WAFFLE_ERROR_UNKNOWN) {
+        switch (waffle_error_get_code()) {
+        case WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM:
+            // fall-through
+        case WAFFLE_ERROR_UNKNOWN:
             // Assume that the native platform rejected the requested
-            // context flavor.
+            // config flavor.
             skip();
-        }
-        else {
+        default:
             assert_true(0);
         }
     }
@@ -338,15 +337,14 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ args)
 
     ts->ctx = waffle_context_create(ts->config, NULL);
     if (ts->ctx == NULL) {
-        if (waffle_error_get_code() == WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM) {
-            skip();
-        }
-        else if (waffle_error_get_code() == WAFFLE_ERROR_UNKNOWN) {
+        switch (waffle_error_get_code()) {
+        case WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM:
+            // fall-through
+        case WAFFLE_ERROR_UNKNOWN:
             // Assume that the native platform rejected the requested
             // context flavor.
             skip();
-        }
-        else {
+        default:
             assert_true(0);
         }
     }
-- 
2.6.2



More information about the waffle mailing list