mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-03 04:16:11 +02:00
net: remove unnecessary casts in socket operations
These methods in the Sock class wrap corresponding syscalls, accepting void* arguments and casting to char* internally, which is needed for Windows support and ignored on other platforms because the syscall itself accepts void*: Send() Recv() GetSockOpt() SetSockOpt()
This commit is contained in:
@@ -1638,7 +1638,7 @@ std::pair<size_t, bool> CConnman::SocketSendData(CNode& node) const
|
||||
flags |= MSG_MORE;
|
||||
}
|
||||
#endif
|
||||
nBytes = node.m_sock->Send(reinterpret_cast<const char*>(data.data()), data.size(), flags);
|
||||
nBytes = node.m_sock->Send(data.data(), data.size(), flags);
|
||||
}
|
||||
if (nBytes > 0) {
|
||||
node.m_last_send = GetTime<std::chrono::seconds>();
|
||||
@@ -3136,7 +3136,7 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError,
|
||||
|
||||
// Allow binding if the port is still in TIME_WAIT state after
|
||||
// the program was closed and restarted.
|
||||
if (sock->SetSockOpt(SOL_SOCKET, SO_REUSEADDR, (sockopt_arg_type)&nOne, sizeof(int)) == SOCKET_ERROR) {
|
||||
if (sock->SetSockOpt(SOL_SOCKET, SO_REUSEADDR, &nOne, sizeof(int)) == SOCKET_ERROR) {
|
||||
strError = Untranslated(strprintf("Error setting SO_REUSEADDR on socket: %s, continuing anyway", NetworkErrorString(WSAGetLastError())));
|
||||
LogPrintf("%s\n", strError.original);
|
||||
}
|
||||
@@ -3145,14 +3145,14 @@ bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError,
|
||||
// and enable it by default or not. Try to enable it, if possible.
|
||||
if (addrBind.IsIPv6()) {
|
||||
#ifdef IPV6_V6ONLY
|
||||
if (sock->SetSockOpt(IPPROTO_IPV6, IPV6_V6ONLY, (sockopt_arg_type)&nOne, sizeof(int)) == SOCKET_ERROR) {
|
||||
if (sock->SetSockOpt(IPPROTO_IPV6, IPV6_V6ONLY, &nOne, sizeof(int)) == SOCKET_ERROR) {
|
||||
strError = Untranslated(strprintf("Error setting IPV6_V6ONLY on socket: %s, continuing anyway", NetworkErrorString(WSAGetLastError())));
|
||||
LogPrintf("%s\n", strError.original);
|
||||
}
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
|
||||
if (sock->SetSockOpt(IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char*)&nProtLevel, sizeof(int)) == SOCKET_ERROR) {
|
||||
if (sock->SetSockOpt(IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, &nProtLevel, sizeof(int)) == SOCKET_ERROR) {
|
||||
strError = Untranslated(strprintf("Error setting IPV6_PROTECTION_LEVEL on socket: %s, continuing anyway", NetworkErrorString(WSAGetLastError())));
|
||||
LogPrintf("%s\n", strError.original);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user