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