Skip to content

Commit

Permalink
Fix compiler warning for argument of getaddrinfo
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stweil committed Nov 9, 2024
1 parent cdb7ff9 commit 49cbe2b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/viewer/svutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 49cbe2b

Please sign in to comment.