summaryrefslogtreecommitdiffstats
path: root/dirmngr
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2019-02-26 04:13:35 +0100
committerNIIBE Yutaka <gniibe@fsij.org>2019-02-26 04:13:35 +0100
commitd661acd483236d34720a4959fc816d05f89c2cb7 (patch)
tree7e546118b6e1d8f0841149618854bfdbc78dd519 /dirmngr
parentlibdns: Avoid using compound literals (6). (diff)
downloadgnupg2-d661acd483236d34720a4959fc816d05f89c2cb7.tar.xz
gnupg2-d661acd483236d34720a4959fc816d05f89c2cb7.zip
libdns: Avoid using compound literals (7).
* dirmngr/dns.h (DNS_OPTS_INIT, dns_opts): Remove. * dirmngr/dns-stuff.c (libdns_res_open): Use zero-ed, and initialized automatic variable for opts. * dirmngr/dns.c (send_query, resolve_query, resolve_addrinfo): Likewise. -- In fact, DNS_OPTS_INIT was only needed when args are none. With partially specified initialization, C99 guarantees zero-ed other members just like static object. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'dirmngr')
-rw-r--r--dirmngr/dns-stuff.c10
-rw-r--r--dirmngr/dns.c15
-rw-r--r--dirmngr/dns.h3
3 files changed, 16 insertions, 12 deletions
diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
index a1aa3145e..e48aca730 100644
--- a/dirmngr/dns-stuff.c
+++ b/dirmngr/dns-stuff.c
@@ -701,6 +701,11 @@ libdns_res_open (ctrl_t ctrl, struct dns_resolver **r_res)
gpg_error_t err;
struct dns_resolver *res;
int derr;
+ struct dns_options opts = { 0 };
+
+ opts.socks_host = &libdns.socks_host;
+ opts.socks_user = tor_socks_user;
+ opts.socks_password = tor_socks_password;
*r_res = NULL;
@@ -726,10 +731,7 @@ libdns_res_open (ctrl_t ctrl, struct dns_resolver **r_res)
set_dns_timeout (0);
res = dns_res_open (libdns.resolv_conf, libdns.hosts, libdns.hints, NULL,
- dns_opts (.socks_host = &libdns.socks_host,
- .socks_user = tor_socks_user,
- .socks_password = tor_socks_password ),
- &derr);
+ &opts, &derr);
if (!res)
return libdns_error_to_gpg_error (derr);
diff --git a/dirmngr/dns.c b/dirmngr/dns.c
index 9da44cd77..fa5e5283d 100644
--- a/dirmngr/dns.c
+++ b/dirmngr/dns.c
@@ -10943,6 +10943,7 @@ static int send_query(int argc, char *argv[]) {
struct sockaddr_storage ss;
struct dns_socket *so;
int error, type;
+ struct dns_options opts = { 0 };
memset(&ss, 0, sizeof ss);
if (argc > 1) {
@@ -10977,7 +10978,7 @@ static int send_query(int argc, char *argv[]) {
fprintf(stderr, "querying %s for %s IN %s\n", host, MAIN.qname, dns_strtype(MAIN.qtype));
- if (!(so = dns_so_open((struct sockaddr *)&resconf()->iface, type, dns_opts(), &error)))
+ if (!(so = dns_so_open((struct sockaddr *)&resconf()->iface, type, &opts, &error)))
panic("dns_so_open: %s", dns_strerror(error));
while (!(A = dns_so_query(so, Q, (struct sockaddr *)&ss, &error))) {
@@ -11061,6 +11062,11 @@ static int resolve_query(int argc DNS_NOTUSED, char *argv[]) {
struct dns_packet *ans;
const struct dns_stat *st;
int error;
+ struct dns_options opts = { 0 };
+
+ opts.socks_host = &MAIN.socks_host;
+ opts.socks_user = MAIN.socks_user;
+ opts.socks_password = MAIN.socks_password;
if (!MAIN.qname)
MAIN.qname = "www.google.com";
@@ -11070,9 +11076,7 @@ static int resolve_query(int argc DNS_NOTUSED, char *argv[]) {
resconf()->options.recurse = recurse;
if (!(R = dns_res_open(resconf(), hosts(), dns_hints_mortal(hints(resconf(), &error)), cache(),
- dns_opts(.socks_host=&MAIN.socks_host,
- .socks_user=MAIN.socks_user,
- .socks_password=MAIN.socks_password), &error)))
+ &opts, &error)))
panic("%s: %s", MAIN.qname, dns_strerror(error));
dns_res_settrace(R, trace("w+b"));
@@ -11116,6 +11120,7 @@ static int resolve_addrinfo(int argc DNS_NOTUSED, char *argv[]) {
struct addrinfo *ent;
char pretty[512];
int error;
+ struct dns_options opts = { 0 };
if (!MAIN.qname)
MAIN.qname = "www.google.com";
@@ -11123,7 +11128,7 @@ static int resolve_addrinfo(int argc DNS_NOTUSED, char *argv[]) {
resconf()->options.recurse = recurse;
- if (!(res = dns_res_open(resconf(), hosts(), dns_hints_mortal(hints(resconf(), &error)), cache(), dns_opts(), &error)))
+ if (!(res = dns_res_open(resconf(), hosts(), dns_hints_mortal(hints(resconf(), &error)), cache(), &opts, &error)))
panic("%s: %s", MAIN.qname, dns_strerror(error));
if (!(ai = dns_ai_open(MAIN.qname, "80", MAIN.qtype, &ai_hints, res, &error)))
diff --git a/dirmngr/dns.h b/dirmngr/dns.h
index 49b1c78bb..afc19a19a 100644
--- a/dirmngr/dns.h
+++ b/dirmngr/dns.h
@@ -1032,9 +1032,6 @@ DNS_PUBLIC void dns_cache_close(struct dns_cache *);
#define DNS_OPTS_INITIALIZER_ { 0, 0 }, 0, 0
#define DNS_OPTS_INITIALIZER { DNS_OPTS_INITIALIZER_ }
-#define DNS_OPTS_INIT(...) { DNS_OPTS_INITIALIZER_, __VA_ARGS__ }
-
-#define dns_opts(...) (&dns_quietinit((struct dns_options)DNS_OPTS_INIT(__VA_ARGS__)))
struct dns_options {
/*