From: Andre Noll Date: Fri, 21 Apr 2017 20:04:09 +0000 (+0200) Subject: net: Always initialize struct sockaddr_storage. X-Git-Tag: v0.6.0~5^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=63128eead92c4e07559b222e2d3d0999be8c82ff net: Always initialize struct sockaddr_storage. The static analyzer of clang claims that the left operand of the condition ss->ss_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&ia6->sin6_addr); in SS_IS_ADDR_V4MAPPED() is a garbage value. The code has been like this for seven years without problems, so the warning is probably bogus. It does not hurt to initialize the sockaddr_storage structures though, which silences the warning. --- diff --git a/net.c b/net.c index fa7cd4b8..eaa1cfb8 100644 --- a/net.c +++ b/net.c @@ -603,7 +603,7 @@ static inline int estimated_header_overhead(const int af_type) */ int generic_max_transport_msg_size(int sockfd) { - struct sockaddr_storage ss; + struct sockaddr_storage ss = {0}; socklen_t sslen = sizeof(ss); int af_type = AF_INET; @@ -629,7 +629,7 @@ int generic_max_transport_msg_size(int sockfd) */ char *remote_name(int fd) { - struct sockaddr_storage ss; + struct sockaddr_storage ss = {0}; const struct sockaddr *sa; socklen_t sslen = sizeof(ss); char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];