From 8a8dc412745a403bf1b75ba30c3bfa81750a0c56 Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakob.olsson@iopsys.eu>
Date: Thu, 17 Sep 2020 09:50:59 +0200
Subject: [PATCH] ubus_api_validator: refactor pass/fail

would fail unconditionally if response was not successful, regardless of return code
---
 ubus_api_validator.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ubus_api_validator.c b/ubus_api_validator.c
index 874276d..6e50f34 100644
--- a/ubus_api_validator.c
+++ b/ubus_api_validator.c
@@ -80,7 +80,7 @@ static int validate_jobj(struct json_object *jobj) {
     const char *defstr = "no result";
 
     int rv = 0;
-    int rv_validation = 0;
+    int rv_validation = 1;
     char *format = NULL;
 
     tmp = json_object_array_get_idx(ubus_methods, i);
@@ -119,12 +119,12 @@ static int validate_jobj(struct json_object *jobj) {
       }
     }
 
-    if (!rv_validation || rc != res->rc) {
+    if (rv_validation && rc == res->rc)
+        ok(true, format);
+    else {
         ok(false, format);
         failed = 1;
-    } else
-        ok(true, format);
-
+    }
     free(res);
   }
 
-- 
GitLab