From f06823264349512d20b9716000dc38d3da281ab3 Mon Sep 17 00:00:00 2001 From: crs Date: Mon, 8 Mar 2004 20:45:53 +0000 Subject: [PATCH] Typecasting fix to compile on old solaris. --- lib/arch/CArchNetworkBSD.cpp | 9 ++++++--- lib/arch/CArchNetworkBSD.h | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/arch/CArchNetworkBSD.cpp b/lib/arch/CArchNetworkBSD.cpp index 44b1a39d..bfdcf20f 100644 --- a/lib/arch/CArchNetworkBSD.cpp +++ b/lib/arch/CArchNetworkBSD.cpp @@ -502,7 +502,8 @@ CArchNetworkBSD::throwErrorOnSocket(CArchSocket s) // get the error from the socket layer int err = 0; socklen_t size = sizeof(err); - if (getsockopt(s->m_fd, SOL_SOCKET, SO_ERROR, &err, &size) == -1) { + if (getsockopt(s->m_fd, SOL_SOCKET, SO_ERROR, + (optval_t*)&err, &size) == -1) { err = errno; } @@ -540,13 +541,15 @@ CArchNetworkBSD::setNoDelayOnSocket(CArchSocket s, bool noDelay) // get old state int oflag; socklen_t size = sizeof(oflag); - if (getsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, &oflag, &size) == -1) { + if (getsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, + (optval_t*)&oflag, &size) == -1) { throwError(errno); } int flag = noDelay ? 1 : 0; size = sizeof(flag); - if (setsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, &flag, size) == -1) { + if (setsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, + (optval_t*)&flag, size) == -1) { throwError(errno); } diff --git a/lib/arch/CArchNetworkBSD.h b/lib/arch/CArchNetworkBSD.h index 2aaf75d7..b656e14a 100644 --- a/lib/arch/CArchNetworkBSD.h +++ b/lib/arch/CArchNetworkBSD.h @@ -25,6 +25,11 @@ typedef int socklen_t; #endif +// old systems may use char* for [gs]etsockopt()'s optval argument. +// this should be void on modern systems but char is forwards +// compatible so we always use it. +typedef char optval_t; + #define ARCH_NETWORK CArchNetworkBSD class CArchSocketImpl {