summaryrefslogtreecommitdiffstats
path: root/src/resolve
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/resolve/resolved-dns-cache.c14
-rw-r--r--src/resolve/resolved-manager.c16
-rw-r--r--src/resolve/resolved-varlink.c14
3 files changed, 18 insertions, 26 deletions
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index 3805150d98..7a1a1620af 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -1407,7 +1407,7 @@ int dns_cache_dump_to_json(DnsCache *cache, JsonVariant **ret) {
_cleanup_(json_variant_unrefp) JsonVariant *l = NULL;
LIST_FOREACH(by_key, j, i) {
- _cleanup_(json_variant_unrefp) JsonVariant *rj = NULL, *item = NULL;
+ _cleanup_(json_variant_unrefp) JsonVariant *rj = NULL;
assert(j->rr);
@@ -1419,13 +1419,11 @@ int dns_cache_dump_to_json(DnsCache *cache, JsonVariant **ret) {
if (r < 0)
return r;
- r = json_build(&item, JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_VARIANT("rr", rj),
- JSON_BUILD_PAIR_BASE64("raw", j->rr->wire_format, j->rr->wire_format_size)));
- if (r < 0)
- return r;
-
- r = json_variant_append_array(&l, item);
+ r = json_variant_append_arrayb(
+ &l,
+ JSON_BUILD_OBJECT(
+ JSON_BUILD_PAIR_VARIANT("rr", rj),
+ JSON_BUILD_PAIR_BASE64("raw", j->rr->wire_format, j->rr->wire_format_size)));
if (r < 0)
return r;
}
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 43e7b95e17..ed3800ed8a 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -1134,7 +1134,7 @@ int manager_monitor_send(
return log_error_errno(r, "Failed to convert question to JSON: %m");
DNS_ANSWER_FOREACH_ITEM(rri, answer) {
- _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL;
+ _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
r = dns_resource_record_to_json(rri->rr, &v);
if (r < 0)
@@ -1144,14 +1144,12 @@ int manager_monitor_send(
if (r < 0)
return log_error_errno(r, "Failed to generate RR wire format: %m");
- r = json_build(&w, JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_CONDITION(v, "rr", JSON_BUILD_VARIANT(v)),
- JSON_BUILD_PAIR("raw", JSON_BUILD_BASE64(rri->rr->wire_format, rri->rr->wire_format_size)),
- JSON_BUILD_PAIR_CONDITION(rri->ifindex > 0, "ifindex", JSON_BUILD_INTEGER(rri->ifindex))));
- if (r < 0)
- return log_error_errno(r, "Failed to make answer RR object: %m");
-
- r = json_variant_append_array(&janswer, w);
+ r = json_variant_append_arrayb(
+ &janswer,
+ JSON_BUILD_OBJECT(
+ JSON_BUILD_PAIR_CONDITION(v, "rr", JSON_BUILD_VARIANT(v)),
+ JSON_BUILD_PAIR("raw", JSON_BUILD_BASE64(rri->rr->wire_format, rri->rr->wire_format_size)),
+ JSON_BUILD_PAIR_CONDITION(rri->ifindex > 0, "ifindex", JSON_BUILD_INTEGER(rri->ifindex))));
if (r < 0)
return log_debug_errno(r, "Failed to append notification entry to array: %m");
}
diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c
index b27cf90435..1ce1a55876 100644
--- a/src/resolve/resolved-varlink.c
+++ b/src/resolve/resolved-varlink.c
@@ -427,7 +427,6 @@ static void vl_method_resolve_address_complete(DnsQuery *query) {
question = dns_query_question_for_protocol(q, q->answer_protocol);
DNS_ANSWER_FOREACH_IFINDEX(rr, ifindex, q->answer) {
- _cleanup_(json_variant_unrefp) JsonVariant *entry = NULL;
_cleanup_free_ char *normalized = NULL;
r = dns_question_matches_rr(question, rr, NULL);
@@ -440,14 +439,11 @@ static void vl_method_resolve_address_complete(DnsQuery *query) {
if (r < 0)
goto finish;
- r = json_build(&entry,
- JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", JSON_BUILD_INTEGER(ifindex)),
- JSON_BUILD_PAIR("name", JSON_BUILD_STRING(normalized))));
- if (r < 0)
- goto finish;
-
- r = json_variant_append_array(&array, entry);
+ r = json_variant_append_arrayb(
+ &array,
+ JSON_BUILD_OBJECT(
+ JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", JSON_BUILD_INTEGER(ifindex)),
+ JSON_BUILD_PAIR("name", JSON_BUILD_STRING(normalized))));
if (r < 0)
goto finish;
}