gpg2/0001-libdns-Avoid-using-compound-literals.patch
Tomáš Chvátal 6a078f40f8 Accepting request 679660 from home:pmonrealgonzalez:branches:Base:System
- Fix build with gcc9 [bsc#1121223]
  * Avoid using compound literals
    - Upstream bug: https://dev.gnupg.org/T4367
  * Added upstream patches:
    - 0001-libdns-Avoid-using-compound-literals.patch
    - 0002-libdns-Avoid-using-compound-literals-2.patch
    - 0003-libdns-Avoid-using-compound-literals-3.patch
    - 0004-libdns-Avoid-using-compound-literals-4.patch
    - 0005-libdns-Avoid-using-compound-literals-5.patch
    - 0006-libdns-Avoid-using-compound-literals-6.patch
    - 0007-libdns-Avoid-using-compound-literals-7.patch
    - 0008-libdns-Avoid-using-compound-literals-8.patch

OBS-URL: https://build.opensuse.org/request/show/679660
OBS-URL: https://build.opensuse.org/package/show/Base:System/gpg2?expand=0&rev=222
2019-02-27 08:22:45 +00:00

95 lines
2.9 KiB
Diff

From 1c405499388fd5bed0968ab5c6c5d1b3373537b9 Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Tue, 26 Feb 2019 09:42:54 +0900
Subject: [PATCH 1/8] libdns: Avoid using compound literals.
* dirmngr/dns.c (dns_inet_pton, dns_so_tcp_keep): Use automatic
variables.
(dns_poll, dns_send_nopipe): Likewise, adding const qualifier.
--
Compound literals is a feature of C99. Because we only use C90 plus
some limited features, in the project, it's better to avoid it.
Besides, we make sure when it's read-only.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
---
dirmngr/dns.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/dirmngr/dns.c b/dirmngr/dns.c
index 210e9f49a..0645d2f55 100644
--- a/dirmngr/dns.c
+++ b/dirmngr/dns.c
@@ -944,10 +944,11 @@ static int dns_sa_cmp(void *a, void *b) {
#if _WIN32
static int dns_inet_pton(int af, const void *src, void *dst) {
union { struct sockaddr_in sin; struct sockaddr_in6 sin6; } u;
+ int size_of_u = (int)sizeof u;
u.sin.sin_family = af;
- if (0 != WSAStringToAddressA((void *)src, af, (void *)0, (struct sockaddr *)&u, &(int){ sizeof u }))
+ if (0 != WSAStringToAddressA((void *)src, af, (void *)0, (struct sockaddr *)&u, &size_of_u))
return -1;
switch (af) {
@@ -1125,6 +1126,7 @@ static inline _Bool dns_isgraph(unsigned char c) {
static int dns_poll(int fd, short events, int timeout) {
fd_set rset, wset;
+ struct timeval tv = { timeout, 0 };
if (!events)
return 0;
@@ -1141,7 +1143,7 @@ static int dns_poll(int fd, short events, int timeout) {
if (events & DNS_POLLOUT)
FD_SET(fd, &wset);
- select(fd + 1, &rset, &wset, 0, (timeout >= 0)? &(struct timeval){ timeout, 0 } : NULL);
+ select(fd + 1, &rset, &wset, 0, (timeout >= 0)? &tv : NULL);
return 0;
} /* dns_poll() */
@@ -1215,9 +1217,10 @@ static size_t dns_send_nopipe(int fd, const void *src, size_t len, int flags, dn
if (!sigismember(&pending, SIGPIPE)) {
int saved = error;
+ const struct timespec ts = { 0, 0 };
if (!count && error == EPIPE) {
- while (-1 == sigtimedwait(&piped, NULL, &(struct timespec){ 0, 0 }) && errno == EINTR)
+ while (-1 == sigtimedwait(&piped, NULL, &ts) && errno == EINTR)
;;
}
@@ -7111,7 +7114,8 @@ static int dns_socket(struct sockaddr *local, int type, int *error_) {
#if defined SO_NOSIGPIPE
if (type != SOCK_DGRAM) {
- if (0 != setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){ 1 }, sizeof (int)))
+ const int v = 1;
+ if (0 != setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &v, sizeof (int)))
goto soerr;
}
#endif
@@ -7487,11 +7491,12 @@ error:
static _Bool dns_so_tcp_keep(struct dns_socket *so) {
struct sockaddr_storage remote;
+ socklen_t l = sizeof remote;
if (so->tcp == -1)
return 0;
- if (0 != getpeername(so->tcp, (struct sockaddr *)&remote, &(socklen_t){ sizeof remote }))
+ if (0 != getpeername(so->tcp, (struct sockaddr *)&remote, &l))
return 0;
return 0 == dns_sa_cmp(&remote, &so->remote);
--
2.20.1