diff --git a/lib/rfcnb/session.c b/lib/rfcnb/session.c index e1ee2b580a1..53e566da520 100644 --- a/lib/rfcnb/session.c +++ b/lib/rfcnb/session.c @@ -295,9 +295,7 @@ RFCNB_Hangup(struct RFCNB_Con *con_Handle) int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, BOOL yn) { - - return (setsockopt(con_Handle->fd, IPPROTO_TCP, TCP_NODELAY, - (char *) &yn, sizeof(yn))); + return setsockopt(con_Handle->fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&yn), sizeof(yn)); } #if NOT_IMPLEMENTED diff --git a/src/WinSvc.cc b/src/WinSvc.cc index 670784a8819..b2c51749b19 100644 --- a/src/WinSvc.cc +++ b/src/WinSvc.cc @@ -965,7 +965,7 @@ static int Win32SockInit(void) } else { opt = opt | SO_SYNCHRONOUS_NONALERT; - if (::setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, optlen)) { + if (::setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, reinterpret_cast(&opt), optlen)) { s_iInitCount = -3; WSACleanup(); return (s_iInitCount); diff --git a/src/client_side.cc b/src/client_side.cc index 3d6f0a5727e..d2dfdcd1d4c 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -2198,7 +2198,7 @@ ConnStateData::start() (transparent() || port->disable_pmtu_discovery == DISABLE_PMTU_ALWAYS)) { #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT) int i = IP_PMTUDISC_DONT; - if (setsockopt(clientConnection->fd, SOL_IP, IP_MTU_DISCOVER, &i, sizeof(i)) < 0) { + if (setsockopt(clientConnection->fd, SOL_IP, IP_MTU_DISCOVER, reinterpret_cast(&i), sizeof(i)) < 0) { int xerrno = errno; debugs(33, 2, "WARNING: Path MTU discovery disabling failed on " << clientConnection << " : " << xstrerr(xerrno)); } diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index c3c7b21d072..1d98e4439ab 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -1772,8 +1772,7 @@ ftpOpenListenSocket(Ftp::Gateway * ftpState, int fallback) if (fallback) { int on = 1; errno = 0; - if (setsockopt(ftpState->ctrl.conn->fd, SOL_SOCKET, SO_REUSEADDR, - (char *) &on, sizeof(on)) == -1) { + if (setsockopt(ftpState->ctrl.conn->fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&on), sizeof(on)) == -1) { int xerrno = errno; // SO_REUSEADDR is only an optimization, no need to be verbose about error debugs(9, 4, "setsockopt failed: " << xstrerr(xerrno)); diff --git a/src/comm.cc b/src/comm.cc index f703786d157..4dc981896c8 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -210,7 +210,7 @@ commSetBindAddressNoPort(const int fd) { #if defined(IP_BIND_ADDRESS_NO_PORT) int flag = 1; - if (setsockopt(fd, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, reinterpret_cast(&flag), sizeof(flag)) < 0) { + if (setsockopt(fd, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, reinterpret_cast(&flag), sizeof(flag)) < 0) { const auto savedErrno = errno; debugs(50, DBG_IMPORTANT, "ERROR: setsockopt(IP_BIND_ADDRESS_NO_PORT) failure: " << xstrerr(savedErrno)); } @@ -293,7 +293,7 @@ static void comm_set_v6only(int fd, int tos) { #ifdef IPV6_V6ONLY - if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &tos, sizeof(int)) < 0) { + if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&tos), sizeof(tos)) < 0) { int xerrno = errno; debugs(50, DBG_IMPORTANT, MYNAME << "setsockopt(IPV6_V6ONLY) " << (tos?"ON":"OFF") << " for FD " << fd << ": " << xstrerr(xerrno)); } @@ -335,7 +335,7 @@ comm_set_transparent(int fd) #if defined(soLevel) && defined(soFlag) int tos = 1; - if (setsockopt(fd, soLevel, soFlag, (char *) &tos, sizeof(int)) < 0) { + if (setsockopt(fd, soLevel, soFlag, reinterpret_cast(&tos), sizeof(tos)) < 0) { int xerrno = errno; debugs(50, DBG_IMPORTANT, MYNAME << "setsockopt(TPROXY) on FD " << fd << ": " << xstrerr(xerrno)); } else { @@ -499,7 +499,7 @@ comm_apply_flags(int new_socket, #if defined(SO_REUSEPORT) if (flags & COMM_REUSEPORT) { int on = 1; - if (setsockopt(new_socket, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast(&on), sizeof(on)) < 0) { + if (setsockopt(new_socket, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast(&on), sizeof(on)) < 0) { const auto savedErrno = errno; const auto errorMessage = ToSBuf("cannot enable SO_REUSEPORT socket option when binding to ", addr, ": ", xstrerr(savedErrno)); @@ -788,7 +788,7 @@ comm_reset_close(const Comm::ConnectionPointer &conn) L.l_onoff = 1; L.l_linger = 0; - if (setsockopt(conn->fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0) { + if (setsockopt(conn->fd, SOL_SOCKET, SO_LINGER, reinterpret_cast(&L), sizeof(L)) < 0) { int xerrno = errno; debugs(50, DBG_CRITICAL, "ERROR: Closing " << conn << " with TCP RST: " << xstrerr(xerrno)); } @@ -803,7 +803,7 @@ old_comm_reset_close(int fd) L.l_onoff = 1; L.l_linger = 0; - if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0) { + if (setsockopt(fd, SOL_SOCKET, SO_LINGER, reinterpret_cast(&L), sizeof(L)) < 0) { int xerrno = errno; debugs(50, DBG_CRITICAL, "ERROR: Closing FD " << fd << " with TCP RST: " << xstrerr(xerrno)); } @@ -1026,7 +1026,7 @@ commSetNoLinger(int fd) L.l_onoff = 0; /* off */ L.l_linger = 0; - if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0) { + if (setsockopt(fd, SOL_SOCKET, SO_LINGER, reinterpret_cast(&L), sizeof(L)) < 0) { int xerrno = errno; debugs(50, DBG_CRITICAL, MYNAME << "FD " << fd << ": " << xstrerr(xerrno)); } @@ -1037,7 +1037,7 @@ static void commSetReuseAddr(int fd) { int on = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0) { + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&on), sizeof(on)) < 0) { int xerrno = errno; debugs(50, DBG_IMPORTANT, MYNAME << "FD " << fd << ": " << xstrerr(xerrno)); } @@ -1046,16 +1046,16 @@ commSetReuseAddr(int fd) static void commSetTcpRcvbuf(int fd, int size) { - if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *) &size, sizeof(size)) < 0) { + if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&size), sizeof(size)) < 0) { int xerrno = errno; debugs(50, DBG_IMPORTANT, MYNAME << "FD " << fd << ", SIZE " << size << ": " << xstrerr(xerrno)); } - if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *) &size, sizeof(size)) < 0) { + if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&size), sizeof(size)) < 0) { int xerrno = errno; debugs(50, DBG_IMPORTANT, MYNAME << "FD " << fd << ", SIZE " << size << ": " << xstrerr(xerrno)); } #ifdef TCP_WINDOW_CLAMP - if (setsockopt(fd, SOL_TCP, TCP_WINDOW_CLAMP, (char *) &size, sizeof(size)) < 0) { + if (setsockopt(fd, SOL_TCP, TCP_WINDOW_CLAMP, reinterpret_cast(&size), sizeof(size)) < 0) { int xerrno = errno; debugs(50, DBG_IMPORTANT, MYNAME << "FD " << fd << ", SIZE " << size << ": " << xstrerr(xerrno)); } @@ -1151,8 +1151,7 @@ static void commSetTcpNoDelay(int fd) { int on = 1; - - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) < 0) { + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&on), sizeof(on)) < 0) { int xerrno = errno; debugs(50, DBG_IMPORTANT, MYNAME << "FD " << fd << ": " << xstrerr(xerrno)); } diff --git a/src/comm/Tcp.cc b/src/comm/Tcp.cc index 43c5da0d9ef..7c47aceb62c 100644 --- a/src/comm/Tcp.cc +++ b/src/comm/Tcp.cc @@ -30,7 +30,7 @@ SetSocketOption(const int fd, const int level, const int optName, const Option & { static_assert(std::is_trivially_copyable