diff options
author | NIIBE Yutaka <[email protected]> | 2019-02-26 02:43:10 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-03-07 12:02:48 +0000 |
commit | 500151e6daf5fc4d6ea382b83aab3cca72b27881 (patch) | |
tree | eb5a2de3c2cfa2340f87d49fb34a85795e8cf6fc | |
parent | libdns: Avoid using compound literals (4). (diff) | |
download | gnupg-500151e6daf5fc4d6ea382b83aab3cca72b27881.tar.gz gnupg-500151e6daf5fc4d6ea382b83aab3cca72b27881.zip |
libdns: Avoid using compound literals (5).
* dirmngr/dns.h (dns_rr_foreach): Don't use dns_rr_i_new.
Call dns_rr_grep with NULL.
* dirmngr/dns.c (dns_rr_grep): Support NULL for error_.
--
Here we still use C99 feature of struct member initialization in
dns_rr_foreach, for struct dns_rr_i. Note that in C99, it guarantees
non-specified member fields are initialized by zero. So, there's no
need to use dns_rr_i_new at all.
Signed-off-by: NIIBE Yutaka <[email protected]>
(cherry picked from commit a1ccfe2b37847cce0db2fb94a7365c9fa501eda4)
Diffstat (limited to '')
-rw-r--r-- | dirmngr/dns.c | 3 | ||||
-rw-r--r-- | dirmngr/dns.h | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/dirmngr/dns.c b/dirmngr/dns.c index eb086fc8e..d4230a8df 100644 --- a/dirmngr/dns.c +++ b/dirmngr/dns.c @@ -3266,7 +3266,8 @@ unsigned dns_rr_grep(struct dns_rr *rr, unsigned lim, struct dns_rr_i *i, struct return count; error: - *error_ = error; + if (error_) + *error_ = error; return count; } /* dns_rr_grep() */ diff --git a/dirmngr/dns.h b/dirmngr/dns.h index 0953228f8..da450c611 100644 --- a/dirmngr/dns.h +++ b/dirmngr/dns.h @@ -542,7 +542,7 @@ DNS_PUBLIC struct dns_rr_i *dns_rr_i_init(struct dns_rr_i *, struct dns_packet * DNS_PUBLIC unsigned dns_rr_grep(struct dns_rr *, unsigned, struct dns_rr_i *, struct dns_packet *, int *); #define dns_rr_foreach_(rr, P, ...) \ - for (struct dns_rr_i DNS_PP_XPASTE(i, __LINE__) = *dns_rr_i_new((P), __VA_ARGS__); dns_rr_grep((rr), 1, &DNS_PP_XPASTE(i, __LINE__), (P), &(int){ 0 }); ) + for (struct dns_rr_i DNS_PP_XPASTE(i, __LINE__) = { __VA_ARGS__ }; dns_rr_grep((rr), 1, &DNS_PP_XPASTE(i, __LINE__), (P), NULL); ) #define dns_rr_foreach(...) dns_rr_foreach_(__VA_ARGS__) |