[OpenWrt-Devel] [PATCH 2/2] Fix use of functions deprecated in json-c.0.12

William Holland william.holland at codethink.co.uk
Thu Feb 26 10:52:42 EST 2015


---
 service/validate.c |   31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/service/validate.c b/service/validate.c
index 0e45493..2297b4d 100644
--- a/service/validate.c
+++ b/service/validate.c
@@ -57,16 +57,27 @@ service_validate_dump_all(struct blob_buf *b, char *p, char *s)
 		if (s && strcmp(s, v->type))
 			continue;
 
-		o = json_object_object_get(r, v->package);
-		if (!o) {
-			o = json_object_new_object();
-			json_object_object_add(r, v->package, o);
-		}
-		t = json_object_object_get(o, v->type);
-		if (!t) {
-			t = json_object_new_object();
-			json_object_object_add(o, v->type, t);
-		}
+		#ifdef JSONC
+			if (!json_object_object_get_ex(r, v->package, &o)) {
+				o = json_object_new_object();
+				json_object_object_add(r, v->package, o);
+			}
+			if (!json_object_object_get_ex(o, v->type, &t)) {
+				t = json_object_new_object();
+				json_object_object_add(o, v->type, t);
+			}
+		#else
+			o = json_object_object_get(r, v->package);
+			if (!o) {
+				o = json_object_new_object();
+				json_object_object_add(r, v->package, o);
+			}
+			t = json_object_object_get(o, v->type);
+			if (!t) {
+				t = json_object_new_object();
+				json_object_object_add(o, v->type, t);
+			}
+		#endif
 		avl_for_each_element(&v->rules, vr, avl)
 			json_object_object_add(t, vr->option, json_object_new_string(vr->rule));
 	}
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list