From 666130346faf921dfaa1a4d30f40ffe5354e14de Mon Sep 17 00:00:00 2001 Message-Id: <666130346faf921dfaa1a4d30f40ffe5354e14de.1715322536.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 26 Apr 2008 15:41:37 +0100 Subject: [PATCH] struct addrinfo varies in order between platforms, forcing us to fall back on C99 initializer syntax. I don't think this will be a huge problem in practice: all the currently supported platforms use GCC as their default compiler, and all vaguely recent versions of GCC support this feature. Organization: Straylight/Edgeware From: Richard Kettlewell --- clients/playrtp.c | 12 ++++-------- lib/client-common.c | 12 ++++-------- lib/sendmail.c | 12 ++++-------- lib/t-addr.c | 11 +++-------- server/speaker-network.c | 24 ++++++++---------------- server/state.c | 12 ++++-------- tests/udplog.c | 12 ++++-------- 7 files changed, 31 insertions(+), 64 deletions(-) diff --git a/clients/playrtp.c b/clients/playrtp.c index 31416ec..6496daf 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -556,14 +556,10 @@ int main(int argc, char **argv) { const char *dumpfile = 0; static const struct addrinfo prefs = { - AI_PASSIVE, - PF_INET, - SOCK_DGRAM, - IPPROTO_UDP, - 0, - 0, - 0, - 0 + .ai_flags = AI_PASSIVE, + .ai_family = PF_INET, + .ai_socktype = SOCK_DGRAM, + .ai_protocol = IPPROTO_UDP }; mem_init(); diff --git a/lib/client-common.c b/lib/client-common.c index d269129..f5ace3e 100644 --- a/lib/client-common.c +++ b/lib/client-common.c @@ -48,14 +48,10 @@ socklen_t find_server(struct sockaddr **sap, char **namep) { socklen_t len; static const struct addrinfo pref = { - 0, - PF_INET, - SOCK_STREAM, - IPPROTO_TCP, - 0, - 0, - 0, - 0 + .ai_flags = 0, + .ai_family = PF_INET, + .ai_socktype = SOCK_STREAM, + .ai_protocol = IPPROTO_TCP, }; if(config->connect.n) { diff --git a/lib/sendmail.c b/lib/sendmail.c index 95ad2a1..2e0df8f 100644 --- a/lib/sendmail.c +++ b/lib/sendmail.c @@ -210,14 +210,10 @@ int sendmail(const char *sender, FILE *in, *out; static const struct addrinfo pref = { - 0, - PF_INET, - SOCK_STREAM, - IPPROTO_TCP, - 0, - 0, - 0, - 0 + .ai_flags = 0, + .ai_family = PF_INET, + .ai_socktype = SOCK_STREAM, + .ai_protocol = IPPROTO_TCP, }; /* Find the SMTP server */ diff --git a/lib/t-addr.c b/lib/t-addr.c index 8b7314d..e609cd9 100644 --- a/lib/t-addr.c +++ b/lib/t-addr.c @@ -29,14 +29,9 @@ void test_addr(void) { struct sockaddr_un su; static const struct addrinfo pref = { - AI_PASSIVE, - PF_INET, - SOCK_STREAM, - 0, - 0, - 0, - 0, - 0 + .ai_flags = AI_PASSIVE, + .ai_family = PF_INET, + .ai_socktype = SOCK_STREAM, }; struct sockaddr_in a1 = { diff --git a/server/speaker-network.c b/server/speaker-network.c index 73d59b8..b77334c 100644 --- a/server/speaker-network.c +++ b/server/speaker-network.c @@ -84,24 +84,16 @@ static int audio_errors; static void network_init(void) { struct addrinfo *res, *sres; static const struct addrinfo pref = { - 0, - PF_INET, - SOCK_DGRAM, - IPPROTO_UDP, - 0, - 0, - 0, - 0 + .ai_flags = 0, + .ai_family = PF_INET, + .ai_socktype = SOCK_DGRAM, + .ai_protocol = IPPROTO_UDP, }; static const struct addrinfo prefbind = { - AI_PASSIVE, - PF_INET, - SOCK_DGRAM, - IPPROTO_UDP, - 0, - 0, - 0, - 0 + .ai_flags = AI_PASSIVE, + .ai_family = PF_INET, + .ai_socktype = SOCK_DGRAM, + .ai_protocol = IPPROTO_UDP, }; static const int one = 1; int sndbuf, target_sndbuf = 131072; diff --git a/server/state.c b/server/state.c index e952556..3adcf2b 100644 --- a/server/state.c +++ b/server/state.c @@ -69,14 +69,10 @@ static void reset_socket(ev_source *ev) { char *name; static const struct addrinfo pref = { - AI_PASSIVE, - PF_INET, - SOCK_STREAM, - IPPROTO_TCP, - 0, - 0, - 0, - 0 + .ai_flags = AI_PASSIVE, + .ai_family = PF_INET, + .ai_socktype = SOCK_STREAM, + .ai_protocol = IPPROTO_TCP, }; /* unix first */ diff --git a/tests/udplog.c b/tests/udplog.c index 0aa8f59..7e580f2 100644 --- a/tests/udplog.c +++ b/tests/udplog.c @@ -81,14 +81,10 @@ int main(int argc, char **argv) { fd_set fds; struct timeval tv; static const struct addrinfo pref = { - 0, /* ai_flags */ - AF_UNSPEC, /* ai_family */ - SOCK_DGRAM, /* ai_socktype */ - IPPROTO_UDP, /* ai_protocol */ - 0, - 0, - 0, - 0 + .ai_flags = 0, + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_DGRAM, + .ai_protocol = IPPROTO_UDP, }; set_progname(argv); -- [mdw]