From 49cbe2b47d7cafe64a8c051d9aa7d9918d4e8c73 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 27 Oct 2024 07:09:32 +0100 Subject: [PATCH] Fix compiler warning for argument of getaddrinfo Fix this clang warning: src/viewer/svutil.cpp:277:51: warning: missing field 'ai_protocol' initializer [-Wmissing-field-initializers] Replace also PF_INET by AF_INET which is the recommended value. Signed-off-by: Stefan Weil --- src/viewer/svutil.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/viewer/svutil.cpp b/src/viewer/svutil.cpp index 7fe6825988..3acce98040 100644 --- a/src/viewer/svutil.cpp +++ b/src/viewer/svutil.cpp @@ -273,8 +273,6 @@ SVNetwork::SVNetwork(const char *hostname, int port) { buffer_ptr_ = nullptr; - struct addrinfo *addr_info = nullptr; - struct addrinfo hints = {0, PF_INET, SOCK_STREAM}; auto port_string = std::to_string(port); # ifdef _WIN32 // Initialize Winsock @@ -285,6 +283,10 @@ SVNetwork::SVNetwork(const char *hostname, int port) { } # endif // _WIN32 + struct addrinfo *addr_info = nullptr; + struct addrinfo hints = {}; + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; if (getaddrinfo(hostname, port_string.c_str(), &hints, &addr_info) != 0) { std::cerr << "Error resolving name for ScrollView host " << std::string(hostname) << ":" << port << std::endl;