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:
parent
72efb78402
commit
7313a112f9
@ -10632,8 +10632,11 @@ static int parse_packet(int argc DNS_NOTUSED, char *argv[] DNS_NOTUSED) {
|
|||||||
#if 0
|
#if 0
|
||||||
dns_rr_foreach(&rr, Q, .name = "ns8.yahoo.com.") {
|
dns_rr_foreach(&rr, Q, .name = "ns8.yahoo.com.") {
|
||||||
#else
|
#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 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);
|
unsigned rrcount = dns_rr_grep(rrset, lengthof(rrset), rri, Q, &error);
|
||||||
|
|
||||||
for (unsigned i = 0; i < rrcount; i++) {
|
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[]) {
|
static int parse_domain(int argc, char *argv[]) {
|
||||||
|
char _p[DNS_D_MAXNAME + 1] = { 0 };
|
||||||
char *dn;
|
char *dn;
|
||||||
|
|
||||||
dn = (argc > 1)? argv[1] : "f.l.google.com";
|
dn = (argc > 1)? argv[1] : "f.l.google.com";
|
||||||
|
|
||||||
printf("[%s]\n", dn);
|
printf("[%s]\n", dn);
|
||||||
|
|
||||||
dn = dns_d_new(dn);
|
dn = dns_d_init(_p, sizeof _p, dn, strlen (dn), DNS_D_ANCHOR);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
puts(dn);
|
puts(dn);
|
||||||
|
@ -451,11 +451,6 @@ DNS_PUBLIC int dns_p_study(struct dns_packet *);
|
|||||||
#define DNS_D_CLEAVE 2 /* cleave sub-domain */
|
#define DNS_D_CLEAVE 2 /* cleave sub-domain */
|
||||||
#define DNS_D_TRIM 4 /* remove superfluous dots */
|
#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 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);
|
DNS_PUBLIC size_t dns_d_anchor(void *, size_t, const void *, size_t);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user