From 07792edb2e6f47ea9c59a0eea56c4906fc40043c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 25 Dec 2008 18:29:08 +0000 Subject: [PATCH] use void pointers, not char ones, in socket IO functions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57546 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/gsockmsw.h | 12 ++++++------ include/wx/private/socket.h | 4 ++-- include/wx/unix/private/sockunix.h | 12 ++++++------ src/msw/gsocket.cpp | 21 +++++++++++---------- src/unix/sockunix.cpp | 16 ++++++++-------- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/include/wx/msw/gsockmsw.h b/include/wx/msw/gsockmsw.h index fe5d5a2942..d65e493b98 100644 --- a/include/wx/msw/gsockmsw.h +++ b/include/wx/msw/gsockmsw.h @@ -40,8 +40,8 @@ public: virtual wxSocketImpl *WaitConnection(wxSocketBase& wxsocket); - int Read(char *buffer, int size); - int Write(const char *buffer, int size); + int Read(void *buffer, int size); + int Write(const void *buffer, int size); private: virtual wxSocketError DoHandleConnect(int ret); @@ -57,10 +57,10 @@ private: wxSocketError Input_Timeout(); wxSocketError Output_Timeout(); wxSocketError Connect_Timeout(); - int Recv_Stream(char *buffer, int size); - int Recv_Dgram(char *buffer, int size); - int Send_Stream(const char *buffer, int size); - int Send_Dgram(const char *buffer, int size); + int Recv_Stream(void *buffer, int size); + int Recv_Dgram(void *buffer, int size); + int Send_Stream(const void *buffer, int size); + int Send_Dgram(const void *buffer, int size); int m_msgnumber; diff --git a/include/wx/private/socket.h b/include/wx/private/socket.h index e1c2f6ad25..530253689f 100644 --- a/include/wx/private/socket.h +++ b/include/wx/private/socket.h @@ -252,8 +252,8 @@ public: // IO operations // ------------- - virtual int Read(char *buffer, int size) = 0; - virtual int Write(const char *buffer, int size) = 0; + virtual int Read(void *buffer, int size) = 0; + virtual int Write(const void *buffer, int size) = 0; wxSocketEventFlags Select(wxSocketEventFlags flags); diff --git a/include/wx/unix/private/sockunix.h b/include/wx/unix/private/sockunix.h index dd83004505..71395e5244 100644 --- a/include/wx/unix/private/sockunix.h +++ b/include/wx/unix/private/sockunix.h @@ -33,8 +33,8 @@ public: virtual void Shutdown(); virtual wxSocketImpl *WaitConnection(wxSocketBase& wxsocket); - int Read(char *buffer, int size); - int Write(const char *buffer, int size); + int Read(void *buffer, int size); + int Write(const void *buffer, int size); //attach or detach from main loop void Notify(bool flag); @@ -103,10 +103,10 @@ private: wxSocketError Input_Timeout(); wxSocketError Output_Timeout(); - int Recv_Stream(char *buffer, int size); - int Recv_Dgram(char *buffer, int size); - int Send_Stream(const char *buffer, int size); - int Send_Dgram(const char *buffer, int size); + int Recv_Stream(void *buffer, int size); + int Recv_Dgram(void *buffer, int size); + int Send_Stream(const void *buffer, int size); + int Send_Dgram(const void *buffer, int size); protected: diff --git a/src/msw/gsocket.cpp b/src/msw/gsocket.cpp index a74fb08bba..c0f8b2f085 100644 --- a/src/msw/gsocket.cpp +++ b/src/msw/gsocket.cpp @@ -230,7 +230,7 @@ wxSocketError wxSocketImplMSW::DoHandleConnect(int ret) /* Generic IO */ /* Like recv(), send(), ... */ -int wxSocketImplMSW::Read(char *buffer, int size) +int wxSocketImplMSW::Read(void *buffer, int size) { int ret; @@ -268,7 +268,7 @@ int wxSocketImplMSW::Read(char *buffer, int size) return ret; } -int wxSocketImplMSW::Write(const char *buffer, int size) +int wxSocketImplMSW::Write(const void *buffer, int size) { int ret; @@ -378,19 +378,20 @@ wxSocketError wxSocketImplMSW::Connect_Timeout() return wxSOCKET_NOERROR; } -int wxSocketImplMSW::Recv_Stream(char *buffer, int size) +int wxSocketImplMSW::Recv_Stream(void *buffer, int size) { - return recv(m_fd, buffer, size, 0); + return recv(m_fd, static_cast(buffer), size, 0); } -int wxSocketImplMSW::Recv_Dgram(char *buffer, int size) +int wxSocketImplMSW::Recv_Dgram(void *buffer, int size) { wxSockAddr from; WX_SOCKLEN_T fromlen = sizeof(from); int ret; wxSocketError err; - ret = recvfrom(m_fd, buffer, size, 0, (sockaddr*)&from, &fromlen); + ret = recvfrom(m_fd, static_cast(buffer), + size, 0, &from, &fromlen); if (ret == SOCKET_ERROR) return SOCKET_ERROR; @@ -417,12 +418,12 @@ int wxSocketImplMSW::Recv_Dgram(char *buffer, int size) return ret; } -int wxSocketImplMSW::Send_Stream(const char *buffer, int size) +int wxSocketImplMSW::Send_Stream(const void *buffer, int size) { - return send(m_fd, buffer, size, 0); + return send(m_fd, static_cast(buffer), size, 0); } -int wxSocketImplMSW::Send_Dgram(const char *buffer, int size) +int wxSocketImplMSW::Send_Dgram(const void *buffer, int size) { struct sockaddr *addr; int len, ret; @@ -441,7 +442,7 @@ int wxSocketImplMSW::Send_Dgram(const char *buffer, int size) return -1; } - ret = sendto(m_fd, buffer, size, 0, addr, len); + ret = sendto(m_fd, static_cast(buffer), size, 0, addr, len); /* Frees memory allocated by _GAddress_translate_to */ free(addr); diff --git a/src/unix/sockunix.cpp b/src/unix/sockunix.cpp index 31c04877c3..3d057f5b81 100644 --- a/src/unix/sockunix.cpp +++ b/src/unix/sockunix.cpp @@ -635,7 +635,7 @@ wxSocketError wxSocketImplUnix::DoHandleConnect(int ret) /* Generic IO */ /* Like recv(), send(), ... */ -int wxSocketImplUnix::Read(char *buffer, int size) +int wxSocketImplUnix::Read(void *buffer, int size) { int ret; @@ -697,7 +697,7 @@ int wxSocketImplUnix::Read(char *buffer, int size) return ret; } -int wxSocketImplUnix::Write(const char *buffer, int size) +int wxSocketImplUnix::Write(const void *buffer, int size) { int ret; @@ -866,7 +866,7 @@ wxSocketError wxSocketImplUnix::Output_Timeout() return wxSOCKET_NOERROR; } -int wxSocketImplUnix::Recv_Stream(char *buffer, int size) +int wxSocketImplUnix::Recv_Stream(void *buffer, int size) { int ret; do @@ -878,7 +878,7 @@ int wxSocketImplUnix::Recv_Stream(char *buffer, int size) return ret; } -int wxSocketImplUnix::Recv_Dgram(char *buffer, int size) +int wxSocketImplUnix::Recv_Dgram(void *buffer, int size) { wxSockAddr from; WX_SOCKLEN_T fromlen = sizeof(from); @@ -919,7 +919,7 @@ int wxSocketImplUnix::Recv_Dgram(char *buffer, int size) return ret; } -int wxSocketImplUnix::Send_Stream(const char *buffer, int size) +int wxSocketImplUnix::Send_Stream(const void *buffer, int size) { int ret; @@ -927,7 +927,7 @@ int wxSocketImplUnix::Send_Stream(const char *buffer, int size) do { - ret = send(m_fd, (char *)buffer, size, GSOCKET_MSG_NOSIGNAL); + ret = send(m_fd, buffer, size, GSOCKET_MSG_NOSIGNAL); } while (ret == -1 && errno == EINTR); /* Loop until not interrupted */ @@ -936,7 +936,7 @@ int wxSocketImplUnix::Send_Stream(const char *buffer, int size) return ret; } -int wxSocketImplUnix::Send_Dgram(const char *buffer, int size) +int wxSocketImplUnix::Send_Dgram(const void *buffer, int size) { struct sockaddr *addr; int len, ret; @@ -959,7 +959,7 @@ int wxSocketImplUnix::Send_Dgram(const char *buffer, int size) do { - ret = sendto(m_fd, (char *)buffer, size, 0, addr, len); + ret = sendto(m_fd, buffer, size, 0, addr, len); } while (ret == -1 && errno == EINTR); /* Loop until not interrupted */ -- 2.45.2