1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-27 18:55:09 +03:00

resolved: get rid of unnecessary if check

DNS_ANSWER_FOREACH() can deal with NULL answers anyway, let's simplify our code here.
This commit is contained in:
Lennart Poettering 2016-01-20 22:07:48 +01:00
parent 839a4a20d8
commit ce736ace37

View File

@ -136,8 +136,9 @@ static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifin
static void bus_method_resolve_hostname_complete(DnsQuery *q) { static void bus_method_resolve_hostname_complete(DnsQuery *q) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *canonical = NULL; _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *canonical = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
DnsResourceRecord *rr;
unsigned added = 0; unsigned added = 0;
int r; int ifindex, r;
assert(q); assert(q);
@ -164,10 +165,6 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
if (r < 0) if (r < 0)
goto finish; goto finish;
if (q->answer) {
DnsResourceRecord *rr;
int ifindex;
DNS_ANSWER_FOREACH_IFINDEX(rr, ifindex, q->answer) { DNS_ANSWER_FOREACH_IFINDEX(rr, ifindex, q->answer) {
DnsQuestion *question; DnsQuestion *question;
@ -188,7 +185,6 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
added ++; added ++;
} }
}
if (added <= 0) { if (added <= 0) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_query_string(q)); r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_query_string(q));