mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
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>
This commit is contained in:
parent
6501e59d36
commit
d661acd483
@ -701,6 +701,11 @@ libdns_res_open (ctrl_t ctrl, struct dns_resolver **r_res)
|
|||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
struct dns_resolver *res;
|
struct dns_resolver *res;
|
||||||
int derr;
|
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;
|
*r_res = NULL;
|
||||||
|
|
||||||
@ -726,10 +731,7 @@ libdns_res_open (ctrl_t ctrl, struct dns_resolver **r_res)
|
|||||||
set_dns_timeout (0);
|
set_dns_timeout (0);
|
||||||
|
|
||||||
res = dns_res_open (libdns.resolv_conf, libdns.hosts, libdns.hints, NULL,
|
res = dns_res_open (libdns.resolv_conf, libdns.hosts, libdns.hints, NULL,
|
||||||
dns_opts (.socks_host = &libdns.socks_host,
|
&opts, &derr);
|
||||||
.socks_user = tor_socks_user,
|
|
||||||
.socks_password = tor_socks_password ),
|
|
||||||
&derr);
|
|
||||||
if (!res)
|
if (!res)
|
||||||
return libdns_error_to_gpg_error (derr);
|
return libdns_error_to_gpg_error (derr);
|
||||||
|
|
||||||
|
@ -10943,6 +10943,7 @@ static int send_query(int argc, char *argv[]) {
|
|||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
struct dns_socket *so;
|
struct dns_socket *so;
|
||||||
int error, type;
|
int error, type;
|
||||||
|
struct dns_options opts = { 0 };
|
||||||
|
|
||||||
memset(&ss, 0, sizeof ss);
|
memset(&ss, 0, sizeof ss);
|
||||||
if (argc > 1) {
|
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));
|
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));
|
panic("dns_so_open: %s", dns_strerror(error));
|
||||||
|
|
||||||
while (!(A = dns_so_query(so, Q, (struct sockaddr *)&ss, &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;
|
struct dns_packet *ans;
|
||||||
const struct dns_stat *st;
|
const struct dns_stat *st;
|
||||||
int error;
|
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)
|
if (!MAIN.qname)
|
||||||
MAIN.qname = "www.google.com";
|
MAIN.qname = "www.google.com";
|
||||||
@ -11070,9 +11076,7 @@ static int resolve_query(int argc DNS_NOTUSED, char *argv[]) {
|
|||||||
resconf()->options.recurse = recurse;
|
resconf()->options.recurse = recurse;
|
||||||
|
|
||||||
if (!(R = dns_res_open(resconf(), hosts(), dns_hints_mortal(hints(resconf(), &error)), cache(),
|
if (!(R = dns_res_open(resconf(), hosts(), dns_hints_mortal(hints(resconf(), &error)), cache(),
|
||||||
dns_opts(.socks_host=&MAIN.socks_host,
|
&opts, &error)))
|
||||||
.socks_user=MAIN.socks_user,
|
|
||||||
.socks_password=MAIN.socks_password), &error)))
|
|
||||||
panic("%s: %s", MAIN.qname, dns_strerror(error));
|
panic("%s: %s", MAIN.qname, dns_strerror(error));
|
||||||
|
|
||||||
dns_res_settrace(R, trace("w+b"));
|
dns_res_settrace(R, trace("w+b"));
|
||||||
@ -11116,6 +11120,7 @@ static int resolve_addrinfo(int argc DNS_NOTUSED, char *argv[]) {
|
|||||||
struct addrinfo *ent;
|
struct addrinfo *ent;
|
||||||
char pretty[512];
|
char pretty[512];
|
||||||
int error;
|
int error;
|
||||||
|
struct dns_options opts = { 0 };
|
||||||
|
|
||||||
if (!MAIN.qname)
|
if (!MAIN.qname)
|
||||||
MAIN.qname = "www.google.com";
|
MAIN.qname = "www.google.com";
|
||||||
@ -11123,7 +11128,7 @@ static int resolve_addrinfo(int argc DNS_NOTUSED, char *argv[]) {
|
|||||||
|
|
||||||
resconf()->options.recurse = recurse;
|
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));
|
panic("%s: %s", MAIN.qname, dns_strerror(error));
|
||||||
|
|
||||||
if (!(ai = dns_ai_open(MAIN.qname, "80", MAIN.qtype, &ai_hints, res, &error)))
|
if (!(ai = dns_ai_open(MAIN.qname, "80", MAIN.qtype, &ai_hints, res, &error)))
|
||||||
|
@ -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_ { 0, 0 }, 0, 0
|
||||||
#define DNS_OPTS_INITIALIZER { DNS_OPTS_INITIALIZER_ }
|
#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 {
|
struct dns_options {
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user