From: Andre Noll Date: Sat, 6 Jul 2013 14:01:26 +0000 (+0200) Subject: extract_v4_addr(): Don't return a structure. X-Git-Tag: v0.5.1~12^2~3 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=61c95753b0a8bc93ae7687fbfb945cc52cf901b6;p=paraslash.git extract_v4_addr(): Don't return a structure. When compiling with -Waggregate-return, gcc issues the following warning: net.c: In function 'extract_v4_addr': net.c:682: warning: function returns an aggregate acl.c: In function 'acl_check_access': acl.c:60: warning: function call has aggregate value It's not entirely clear how bad it is these days to return a structure, but extract_v4_addr() is the only function in the tree which does it. Since it can be easily changed to take a pointer instead and there is only a single caller, let's implement it this way. --- diff --git a/acl.c b/acl.c index 60f835ae..e70ab9b3 100644 --- a/acl.c +++ b/acl.c @@ -57,7 +57,7 @@ static int acl_lookup(int fd, struct list_head *acl) PARA_ERROR_LOG("Can not determine peer address: %s\n", strerror(errno)); goto no_match; } - v4_addr = extract_v4_addr(&ss); + extract_v4_addr(&ss, &v4_addr); if (!v4_addr.s_addr) goto no_match; diff --git a/net.c b/net.c index 2ec3f03e..4a31f013 100644 --- a/net.c +++ b/net.c @@ -672,19 +672,19 @@ char *remote_name(int sockfd) /** * Extract IPv4 or IPv6-mapped-IPv4 address from sockaddr_storage. - * \param ss Container of IPv4/6 address - * \return Extracted IPv4 address (different from 0) or 0 if unsuccessful. * - * \sa RFC 3493 + * \param ss Container of IPv4/6 address. + * \param ia Extracted IPv4 address (different from 0) or 0 if unsuccessful. + * + * \sa RFC 3493. */ -struct in_addr extract_v4_addr(const struct sockaddr_storage *ss) +void extract_v4_addr(const struct sockaddr_storage *ss, struct in_addr *ia) { - struct in_addr ia = {.s_addr = 0}; const struct sockaddr *sa = normalize_ip_address(ss); + memset(ia, 0, sizeof(*ia)); if (sa->sa_family == AF_INET) - ia = ((struct sockaddr_in *)sa)->sin_addr; - return ia; + *ia = ((struct sockaddr_in *)sa)->sin_addr; } /** diff --git a/net.h b/net.h index ae5e8015..0003fa9d 100644 --- a/net.h +++ b/net.h @@ -114,7 +114,7 @@ static inline int para_connect_simple(unsigned l4type, return makesock(l4type, 0, host, port, NULL); } -extern struct in_addr extract_v4_addr(const struct sockaddr_storage *ss); +void extract_v4_addr(const struct sockaddr_storage *ss, struct in_addr *ia); /** * Functions to support listening sockets.