]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
net.c: Silence clang warning.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 11 Jun 2017 10:13:22 +0000 (12:13 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 14 Jun 2017 17:54:01 +0000 (19:54 +0200)
clang-3.8.0 on FreeBSD complains about a recent change to net.c:

net.c:606:33: warning: missing field 'ss_family' initializer [-Wmissing-field-initializers]
struct sockaddr_storage ss = {0};
       ^
This line was introduced in commit 63128eea (net: Always initialize
struct sockaddr_storage) to avoid a warning from the static analyzer
of clang. Setting .ss_family initializes all struct members, which
makes both the analyzer and the compiler happy again.

net.c

diff --git a/net.c b/net.c
index 6c23fdd9ce6b248e562e84c23d3e089e4484b178..50243673eaf9f3e22edf7aa0cea0247b5917cdeb 100644 (file)
--- 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)
 {
  */
 int generic_max_transport_msg_size(int sockfd)
 {
-       struct sockaddr_storage ss = {0};
+       struct sockaddr_storage ss = {.ss_family = 0};
        socklen_t sslen = sizeof(ss);
        int af_type = AF_INET;
 
        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)
 {
  */
 char *remote_name(int fd)
 {
-       struct sockaddr_storage ss = {0};
+       struct sockaddr_storage ss = {.ss_family = 0};
        const struct sockaddr *sa;
        socklen_t sslen = sizeof(ss);
        char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
        const struct sockaddr *sa;
        socklen_t sslen = sizeof(ss);
        char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];