Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-26086 Fix Coverity scan issues in httplib #18001

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions system/httplib/httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,17 +546,17 @@ using SocketOptions = std::function<void(socket_t sock)>;
inline void default_socket_options(socket_t sock) {
int yes = 1;
#ifdef _WIN32
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&yes),
sizeof(yes));
setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
reinterpret_cast<char *>(&yes), sizeof(yes));
(void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&yes),
sizeof(yes));
(void)setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
reinterpret_cast<char *>(&yes), sizeof(yes));
#else
#ifdef SO_REUSEPORT
(void)setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast<void *>(&yes),
sizeof(yes));
sizeof(yes));
#else
(void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<void *>(&yes),
sizeof(yes));
sizeof(yes));
#endif
#endif
}
Expand Down Expand Up @@ -1858,15 +1858,15 @@ socket_t create_socket(const char *host, int port, int socket_flags,
if (tcp_nodelay) {
int yes = 1;
(void)setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char *>(&yes),
sizeof(yes));
sizeof(yes));
}

if (socket_options) { socket_options(sock); }

if (rp->ai_family == AF_INET6) {
int no = 0;
(void)setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<char *>(&no),
sizeof(no));
sizeof(no));
}

// bind or connect
Expand Down Expand Up @@ -5586,16 +5586,16 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl,
tv.tv_sec = static_cast<long>(read_timeout_sec);
tv.tv_usec = static_cast<decltype(tv.tv_usec)>(read_timeout_usec);

setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<char *>(&tv),
sizeof(tv));
(void)setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<char *>(&tv),
sizeof(tv));
}
{
timeval tv;
tv.tv_sec = static_cast<long>(write_timeout_sec);
tv.tv_usec = static_cast<decltype(tv.tv_usec)>(write_timeout_usec);

setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast<char *>(&tv),
sizeof(tv));
(void)setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast<char *>(&tv),
sizeof(tv));
}
}

Expand Down
Loading