Blame SOURCES/0038-stop-using-deprecated-json-c-functions.patch

4b6aa8
From 712ca27bdbbe4f38550d5431b400dfa9e70de744 Mon Sep 17 00:00:00 2001
4b6aa8
From: Jakub Filak <jfilak@redhat.com>
4b6aa8
Date: Fri, 18 Apr 2014 14:42:03 +0200
4b6aa8
Subject: [LIBREPORT PATCH 38/38] stop using deprecated json-c functions
4b6aa8
4b6aa8
Resolves: #1125743
4b6aa8
4b6aa8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
4b6aa8
---
4b6aa8
 src/plugins/ureport.c | 44 +++++++++++++++++---------------------------
4b6aa8
 1 file changed, 17 insertions(+), 27 deletions(-)
4b6aa8
4b6aa8
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
4b6aa8
index 39d27f6..59554f4 100644
4b6aa8
--- a/src/plugins/ureport.c
4b6aa8
+++ b/src/plugins/ureport.c
4b6aa8
@@ -157,16 +157,13 @@ static char *parse_solution_from_json_list(struct json_object *list, GList **rep
4b6aa8
         if (!list_elem)
4b6aa8
             continue;
4b6aa8
 
4b6aa8
-        struct_elem = json_object_object_get(list_elem, "cause");
4b6aa8
-        if (!struct_elem)
4b6aa8
+        if (!json_object_object_get_ex(list_elem, "cause", &struct_elem))
4b6aa8
             continue;
4b6aa8
 
4b6aa8
         cause = json_object_get_string(struct_elem);
4b6aa8
-        if (!cause)
4b6aa8
             continue;
4b6aa8
 
4b6aa8
-        struct_elem = json_object_object_get(list_elem, "note");
4b6aa8
-        if (!struct_elem)
4b6aa8
+        if (!json_object_object_get_ex(list_elem, "note", &struct_elem))
4b6aa8
             continue;
4b6aa8
 
4b6aa8
         note = json_object_get_string(struct_elem);
4b6aa8
@@ -176,8 +173,7 @@ static char *parse_solution_from_json_list(struct json_object *list, GList **rep
4b6aa8
         empty = false;
4b6aa8
         strbuf_append_strf(solution_buf, one_format, cause, note);
4b6aa8
 
4b6aa8
-        struct_elem = json_object_object_get(list_elem, "url");
4b6aa8
-        if (!struct_elem)
4b6aa8
+        if (!json_object_object_get_ex(list_elem, "url", &struct_elem))
4b6aa8
             continue;
4b6aa8
 
4b6aa8
         url = json_object_get_string(struct_elem);
4b6aa8
@@ -216,24 +212,21 @@ static GList *parse_reported_to_from_json_list(struct json_object *list)
4b6aa8
         if (!list_elem)
4b6aa8
             continue;
4b6aa8
 
4b6aa8
-        struct_elem = json_object_object_get(list_elem, "reporter");
4b6aa8
-        if (!struct_elem)
4b6aa8
+        if (!json_object_object_get_ex(list_elem, "reporter", &struct_elem))
4b6aa8
             continue;
4b6aa8
 
4b6aa8
         reporter = json_object_get_string(struct_elem);
4b6aa8
         if (!reporter)
4b6aa8
             continue;
4b6aa8
 
4b6aa8
-        struct_elem = json_object_object_get(list_elem, "value");
4b6aa8
-        if (!struct_elem)
4b6aa8
+        if (!json_object_object_get_ex(list_elem, "value", &struct_elem))
4b6aa8
             continue;
4b6aa8
 
4b6aa8
         value = json_object_get_string(struct_elem);
4b6aa8
         if (!value)
4b6aa8
             continue;
4b6aa8
 
4b6aa8
-        struct_elem = json_object_object_get(list_elem, "type");
4b6aa8
-        if (!struct_elem)
4b6aa8
+        if (!json_object_object_get_ex(list_elem, "type", &struct_elem))
4b6aa8
             continue;
4b6aa8
 
4b6aa8
         type = json_object_get_string(struct_elem);
4b6aa8
@@ -265,9 +258,8 @@ static GList *parse_reported_to_from_json_list(struct json_object *list)
4b6aa8
  */
4b6aa8
 static struct ureport_server_response *ureport_server_parse_json(json_object *json)
4b6aa8
 {
4b6aa8
-    json_object *obj = json_object_object_get(json, "error");
4b6aa8
-
4b6aa8
-    if (obj)
4b6aa8
+    json_object *obj = NULL;
4b6aa8
+    if (json_object_object_get_ex(json, "error", &obj))
4b6aa8
     {
4b6aa8
         struct ureport_server_response *out_response = xzalloc(sizeof(*out_response));
4b6aa8
         out_response->is_error = true;
4b6aa8
@@ -279,27 +271,25 @@ static struct ureport_server_response *ureport_server_parse_json(json_object *js
4b6aa8
         return out_response;
4b6aa8
     }
4b6aa8
 
4b6aa8
-    obj = json_object_object_get(json, "result");
4b6aa8
-
4b6aa8
-    if (obj)
4b6aa8
+    if (json_object_object_get_ex(json, "result", &obj))
4b6aa8
     {
4b6aa8
         struct ureport_server_response *out_response = xzalloc(sizeof(*out_response));
4b6aa8
         out_response->value = xstrdup(json_object_get_string(obj));
4b6aa8
 
4b6aa8
-        json_object *message = json_object_object_get(json, "message");
4b6aa8
-        if (message)
4b6aa8
+        json_object *message = NULL;
4b6aa8
+        if (json_object_object_get_ex(json, "message", &message))
4b6aa8
             out_response->message = xstrdup(json_object_get_string(message));
4b6aa8
 
4b6aa8
-        json_object *bthash = json_object_object_get(json, "bthash");
4b6aa8
-        if (bthash)
4b6aa8
+        json_object *bthash = NULL;
4b6aa8
+        if (json_object_object_get_ex(json, "bthash", &bthash))
4b6aa8
             out_response->bthash = xstrdup(json_object_get_string(bthash));
4b6aa8
 
4b6aa8
-        json_object *reported_to_list = json_object_object_get(json, "reported_to");
4b6aa8
-        if (reported_to_list)
4b6aa8
+        json_object *reported_to_list = NULL;
4b6aa8
+        if (json_object_object_get_ex(json, "reported_to", &reported_to_list))
4b6aa8
             out_response->reported_to_list = parse_reported_to_from_json_list(reported_to_list);
4b6aa8
 
4b6aa8
-        json_object *solutions = json_object_object_get(json, "solutions");
4b6aa8
-        if (solutions)
4b6aa8
+        json_object *solutions = NULL;
4b6aa8
+        if (json_object_object_get_ex(json, "solutions", &solutions))
4b6aa8
             out_response->solution = parse_solution_from_json_list(solutions, &(out_response->reported_to_list));
4b6aa8
 
4b6aa8
         return out_response;
4b6aa8
-- 
4b6aa8
1.8.3.1
4b6aa8