diff mbox

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

Message ID 1424965962-16298-3-git-send-email-william.holland@codethink.co.uk
State Superseded
Headers show

Commit Message

William Holland Feb. 26, 2015, 3:52 p.m. UTC
---
 service/validate.c |   31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

Comments

Karl Palsson Feb. 27, 2015, 10:25 a.m. UTC | #1
These have been deprecated for a very long time, the alternative
functions have been available since json-c 10 and 11 were pushed in AA
branch.  I don't think there should be any need to keep the older form
in the #def, just only support the newer style.

Sincerely,
Karl P

William Holland <william.holland@codethink.co.uk> wrote:
> ---
>  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@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
diff mbox

Patch

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));
 	}