1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

libdns: Avoid using compound literals (4).

* dirmngr/dns.h (dns_d_new*): Remove.
* dirmngr/dns.c (parse_packet): Use dns_d_init with automatic
variable.
(parse_domain): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-02-26 10:58:16 +09:00
parent 72efb78402
commit 7313a112f9
2 changed files with 6 additions and 7 deletions

View File

@ -10632,8 +10632,11 @@ static int parse_packet(int argc DNS_NOTUSED, char *argv[] DNS_NOTUSED) {
#if 0
dns_rr_foreach(&rr, Q, .name = "ns8.yahoo.com.") {
#else
char _p[DNS_D_MAXNAME + 1] = { 0 };
const char *dn = "ns8.yahoo.com";
char *_name = dns_d_init(_p, sizeof _p, dn, strlen (dn), DNS_D_ANCHOR);
struct dns_rr rrset[32];
struct dns_rr_i *rri = dns_rr_i_new(Q, .name = dns_d_new("ns8.yahoo.com", DNS_D_ANCHOR), .sort = MAIN.sort);
struct dns_rr_i *rri = dns_rr_i_new(Q, .name = _name, .sort = MAIN.sort);
unsigned rrcount = dns_rr_grep(rrset, lengthof(rrset), rri, Q, &error);
for (unsigned i = 0; i < rrcount; i++) {
@ -10661,13 +10664,14 @@ static int parse_packet(int argc DNS_NOTUSED, char *argv[] DNS_NOTUSED) {
static int parse_domain(int argc, char *argv[]) {
char _p[DNS_D_MAXNAME + 1] = { 0 };
char *dn;
dn = (argc > 1)? argv[1] : "f.l.google.com";
printf("[%s]\n", dn);
dn = dns_d_new(dn);
dn = dns_d_init(_p, sizeof _p, dn, strlen (dn), DNS_D_ANCHOR);
do {
puts(dn);

View File

@ -451,11 +451,6 @@ DNS_PUBLIC int dns_p_study(struct dns_packet *);
#define DNS_D_CLEAVE 2 /* cleave sub-domain */
#define DNS_D_TRIM 4 /* remove superfluous dots */
#define dns_d_new3(a, b, f) dns_d_init(&(char[DNS_D_MAXNAME + 1]){ 0 }, DNS_D_MAXNAME + 1, (a), (b), (f))
#define dns_d_new2(a, f) dns_d_new3((a), strlen((a)), (f))
#define dns_d_new1(a) dns_d_new3((a), strlen((a)), DNS_D_ANCHOR)
#define dns_d_new(...) DNS_PP_CALL(DNS_PP_XPASTE(dns_d_new, DNS_PP_NARG(__VA_ARGS__)), __VA_ARGS__)
DNS_PUBLIC char *dns_d_init(void *, size_t, const void *, size_t, int);
DNS_PUBLIC size_t dns_d_anchor(void *, size_t, const void *, size_t);