From c9f2f38b0f510bde4056ad63e1d5e6d045536172 Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakob.olsson@iopsys.eu>
Date: Tue, 15 Sep 2020 17:23:29 +0200
Subject: [PATCH] ubus_api_validator: refactor pass/fail logic

---
 ubus_api_validator.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/ubus_api_validator.c b/ubus_api_validator.c
index 6557b4d..874276d 100644
--- a/ubus_api_validator.c
+++ b/ubus_api_validator.c
@@ -119,13 +119,11 @@ static int validate_jobj(struct json_object *jobj) {
       }
     }
 
-    // rc == res->rc handles negative testing
-    if (rv_validation || (rc == res->rc)) {
-      ok(true, format);
-    } else {
-      ok(false, format);
-      failed = 1;
-    }
+    if (!rv_validation || rc != res->rc) {
+        ok(false, format);
+        failed = 1;
+    } else
+        ok(true, format);
 
     free(res);
   }
-- 
GitLab