Fix compiler warning for argument of getaddrinfo
Some checks failed
CodeQL / Analyze (cpp) (push) Has been cancelled
sw / build (fedora:latest, ubuntu-22.04) (push) Has been cancelled
sw / build (macos-latest) (push) Has been cancelled
sw / build (windows-2022) (push) Has been cancelled
unittest-disablelegacy / linux (clang++-15, ubuntu-22.04) (push) Has been cancelled
unittest-disablelegacy / linux (g++, ubuntu-22.04) (push) Has been cancelled
msys2 / windows (mingw-w64-x86_64, MINGW64) (push) Has been cancelled

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 <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2024-10-27 07:09:32 +01:00
parent cdb7ff90e4
commit 49cbe2b47d

View File

@ -273,8 +273,6 @@ SVNetwork::SVNetwork(const char *hostname, int port) {
buffer_ptr_ = nullptr; buffer_ptr_ = nullptr;
struct addrinfo *addr_info = nullptr;
struct addrinfo hints = {0, PF_INET, SOCK_STREAM};
auto port_string = std::to_string(port); auto port_string = std::to_string(port);
# ifdef _WIN32 # ifdef _WIN32
// Initialize Winsock // Initialize Winsock
@ -285,6 +283,10 @@ SVNetwork::SVNetwork(const char *hostname, int port) {
} }
# endif // _WIN32 # 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) { if (getaddrinfo(hostname, port_string.c_str(), &hints, &addr_info) != 0) {
std::cerr << "Error resolving name for ScrollView host " std::cerr << "Error resolving name for ScrollView host "
<< std::string(hostname) << ":" << port << std::endl; << std::string(hostname) << ":" << port << std::endl;