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