]> git.meshlink.io Git - meshlink/blobdiff - src/netutl.c
Fix all compiler warnings found using -Wall -W -pedantic.
[meshlink] / src / netutl.c
index f41fbecc2ea3e502bd4dad5e9cdc42d961eedc6a..d38b1a18aeb8468e1ac82ff40076b4c79720d54f 100644 (file)
@@ -32,11 +32,13 @@ bool hostnames = false;
   Return NULL on failure.
 */
 struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) {
-       struct addrinfo *ai, hint = {};
+       struct addrinfo *ai;
        int err;
 
-       hint.ai_family = addressfamily;
-       hint.ai_socktype = socktype;
+       struct addrinfo hint = {
+               .ai_family = addressfamily,
+               .ai_socktype = socktype,
+       };
 
        err = getaddrinfo(address, service, &hint, &ai);
 
@@ -49,13 +51,15 @@ struct addrinfo *str2addrinfo(const char *address, const char *service, int sock
 }
 
 sockaddr_t str2sockaddr(const char *address, const char *port) {
-       struct addrinfo *ai, hint = {};
-       sockaddr_t result = {};
+       struct addrinfo *ai;
+       sockaddr_t result;
        int err;
 
-       hint.ai_family = AF_UNSPEC;
-       hint.ai_flags = AI_NUMERICHOST;
-       hint.ai_socktype = SOCK_STREAM;
+       struct addrinfo hint = {
+               .ai_family = AF_UNSPEC,
+               .ai_flags = AI_NUMERICHOST,
+               .ai_socktype = SOCK_STREAM,
+       };
 
        err = getaddrinfo(address, port, &hint, &ai);