2de02a0a4a
OBS-URL: https://build.opensuse.org/request/show/679738 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gpg2?expand=0&rev=136
136 lines
4.9 KiB
Diff
136 lines
4.9 KiB
Diff
From 72efb7840258808cd892b90d871ea1cc1c31d7f5 Mon Sep 17 00:00:00 2001
|
|
From: NIIBE Yutaka <gniibe@fsij.org>
|
|
Date: Tue, 26 Feb 2019 10:34:03 +0900
|
|
Subject: [PATCH 3/8] libdns: Avoid using compound literals (3).
|
|
|
|
* dirmngr/dns.h (dns_p_new): Remove.
|
|
* dirmngr/dns.c (dns_hosts_query): Use dns_p_init with automatic
|
|
variable.
|
|
(dns_hints_query, dns_res_glue, parse_packet, query_hosts)
|
|
(send_query, show_hints, echo_port): Likewise.
|
|
|
|
--
|
|
|
|
Implicit automatic allocation by compound literals is confusing
|
|
for C90 code.
|
|
|
|
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
|
|
---
|
|
dirmngr/dns.c | 27 ++++++++++++++++++---------
|
|
dirmngr/dns.h | 3 ---
|
|
2 files changed, 18 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/dirmngr/dns.c b/dirmngr/dns.c
|
|
index 92084d112..6acb4faa2 100644
|
|
--- a/dirmngr/dns.c
|
|
+++ b/dirmngr/dns.c
|
|
@@ -5278,7 +5278,8 @@ error:
|
|
|
|
|
|
struct dns_packet *dns_hosts_query(struct dns_hosts *hosts, struct dns_packet *Q, int *error_) {
|
|
- struct dns_packet *P = dns_p_new(512);
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _P = { 0 };
|
|
+ struct dns_packet *P = dns_p_init(&_P.p, 512);
|
|
struct dns_packet *A = 0;
|
|
struct dns_rr rr;
|
|
struct dns_hosts_entry *ent;
|
|
@@ -6839,6 +6840,7 @@ unsigned dns_hints_grep(struct sockaddr **sa, socklen_t *sa_len, unsigned lim, s
|
|
|
|
|
|
struct dns_packet *dns_hints_query(struct dns_hints *hints, struct dns_packet *Q, int *error_) {
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _P = { 0 };
|
|
struct dns_packet *A, *P;
|
|
struct dns_rr rr;
|
|
char zone[DNS_D_MAXNAME + 1];
|
|
@@ -6856,7 +6858,7 @@ struct dns_packet *dns_hints_query(struct dns_hints *hints, struct dns_packet *Q
|
|
else if (zlen >= sizeof zone)
|
|
goto toolong;
|
|
|
|
- P = dns_p_new(512);
|
|
+ P = dns_p_init(&_P.p, 512);
|
|
dns_header(P)->qr = 1;
|
|
|
|
if ((error = dns_rr_copy(P, &rr, Q)))
|
|
@@ -8461,7 +8463,8 @@ error:
|
|
|
|
|
|
static struct dns_packet *dns_res_glue(struct dns_resolver *R, struct dns_packet *Q) {
|
|
- struct dns_packet *P = dns_p_new(512);
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _P = { 0 };
|
|
+ struct dns_packet *P = dns_p_init(&_P.p, 512);
|
|
char qname[DNS_D_MAXNAME + 1];
|
|
size_t qlen;
|
|
enum dns_type qtype;
|
|
@@ -10586,8 +10589,10 @@ static void print_packet(struct dns_packet *P, FILE *fp) {
|
|
|
|
|
|
static int parse_packet(int argc DNS_NOTUSED, char *argv[] DNS_NOTUSED) {
|
|
- struct dns_packet *P = dns_p_new(512);
|
|
- struct dns_packet *Q = dns_p_new(512);
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _P = { 0 };
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _Q = { 0 };
|
|
+ struct dns_packet *P = dns_p_init(&_P.p, 512);
|
|
+ struct dns_packet *Q = dns_p_init(&_Q.p, 512);
|
|
enum dns_section section;
|
|
struct dns_rr rr;
|
|
int error;
|
|
@@ -10787,7 +10792,8 @@ static int show_hosts(int argc DNS_NOTUSED, char *argv[] DNS_NOTUSED) {
|
|
|
|
|
|
static int query_hosts(int argc, char *argv[]) {
|
|
- struct dns_packet *Q = dns_p_new(512);
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _Q = { 0 };
|
|
+ struct dns_packet *Q = dns_p_init(&_Q.p, 512);
|
|
struct dns_packet *A;
|
|
char qname[DNS_D_MAXNAME + 1];
|
|
size_t qlen;
|
|
@@ -10905,7 +10911,8 @@ static int dump_random(int argc, char *argv[]) {
|
|
|
|
|
|
static int send_query(int argc, char *argv[]) {
|
|
- struct dns_packet *A, *Q = dns_p_new(512);
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _Q = { 0 };
|
|
+ struct dns_packet *A, *Q = dns_p_init(&_Q.p, 512);
|
|
char host[INET6_ADDRSTRLEN + 1];
|
|
struct sockaddr_storage ss;
|
|
struct dns_socket *so;
|
|
@@ -10999,9 +11006,10 @@ static int show_hints(int argc, char *argv[]) {
|
|
if (0 == strcmp(how, "plain")) {
|
|
dns_hints_dump(hints, stdout);
|
|
} else {
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _P = { 0 };
|
|
struct dns_packet *query, *answer;
|
|
|
|
- query = dns_p_new(512);
|
|
+ query = dns_p_init(&_P.p, 512);
|
|
|
|
if ((error = dns_p_push(query, DNS_S_QUESTION, who, strlen(who), DNS_T_A, DNS_C_IN, 0, 0)))
|
|
panic("%s: %s", who, dns_strerror(error));
|
|
@@ -11160,7 +11168,8 @@ static int echo_port(int argc DNS_NOTUSED, char *argv[] DNS_NOTUSED) {
|
|
panic("127.0.0.1:5353: %s", dns_strerror(errno));
|
|
|
|
for (;;) {
|
|
- struct dns_packet *pkt = dns_p_new(512);
|
|
+ union { unsigned char b[dns_p_calcsize((512))]; struct dns_packet p; } _P = { 0 };
|
|
+ struct dns_packet *pkt = dns_p_init(&_P.p, 512);
|
|
struct sockaddr_storage ss;
|
|
socklen_t slen = sizeof ss;
|
|
ssize_t count;
|
|
diff --git a/dirmngr/dns.h b/dirmngr/dns.h
|
|
index 6dedfbc91..4a9417120 100644
|
|
--- a/dirmngr/dns.h
|
|
+++ b/dirmngr/dns.h
|
|
@@ -412,9 +412,6 @@ struct dns_packet {
|
|
|
|
#define dns_p_sizeof(P) dns_p_calcsize((P)->end)
|
|
|
|
-/** takes size of maximum desired payload */
|
|
-#define dns_p_new(n) (dns_p_init((struct dns_packet *)&(union { unsigned char b[dns_p_calcsize((n))]; struct dns_packet p; }){ { 0 } }, dns_p_calcsize((n))))
|
|
-
|
|
/** takes size of entire packet structure as allocated */
|
|
DNS_PUBLIC struct dns_packet *dns_p_init(struct dns_packet *, size_t);
|
|
|
|
--
|
|
2.20.1
|
|
|