Fix deutil and decpp -Wconversion warnings.
authorJarkko Pöyry <jpoyry@google.com>
Tue, 19 May 2015 19:24:51 +0000 (12:24 -0700)
committerJarkko Pöyry <jpoyry@google.com>
Wed, 20 May 2015 18:11:21 +0000 (11:11 -0700)
- Updated sockets to use size_t as data size.
- Updated executor and execserver to build on new api and use size_t
  for data sizes. Protocol is not modified.

Bug: 21161908
Change-Id: Ic525e05ef9a28ac80d8a6bcf5e239a70a89a5172

24 files changed:
execserver/tools/xsClient.cpp
execserver/tools/xsTest.cpp
execserver/xsExecutionServer.cpp
execserver/xsExecutionServer.hpp
execserver/xsProtocol.cpp
execserver/xsProtocol.hpp
executor/xeBatchExecutor.cpp
executor/xeBatchExecutor.hpp
executor/xeCallQueue.cpp
executor/xeCallQueue.hpp
executor/xeCommLink.hpp
executor/xeTcpIpLink.cpp
executor/xeTcpIpLink.hpp
executor/xeTestResultParser.cpp
framework/delibs/decpp/deBlockBuffer.cpp
framework/delibs/decpp/dePoolArray.hpp
framework/delibs/decpp/deSocket.hpp
framework/delibs/decpp/deThreadSafeRingBuffer.cpp
framework/delibs/deutil/deCommandLine.c
framework/delibs/deutil/deFile.c
framework/delibs/deutil/deProcess.c
framework/delibs/deutil/deSocket.c
framework/delibs/deutil/deSocket.h
framework/delibs/deutil/deTimerTest.c

index eb71fe6..e680fc9 100644 (file)
@@ -67,11 +67,11 @@ void sendMessage (de::Socket& socket, const Message& message)
        message.write(buf);
 
        // Write to socket.
-       int pos = 0;
-       while (pos < (int)buf.size())
+       size_t pos = 0;
+       while (pos < buf.size())
        {
-               int                             numLeft         = (int)buf.size() - pos;
-               int                             numSent         = 0;
+               size_t                  numLeft         = buf.size() - pos;
+               size_t                  numSent         = 0;
                deSocketResult  result          = socket.send(&buf[pos], numLeft, &numSent);
 
                if (result != DE_SOCKETRESULT_SUCCESS)
@@ -81,14 +81,14 @@ void sendMessage (de::Socket& socket, const Message& message)
        }
 }
 
-void readBytes (de::Socket& socket, vector<deUint8>& dst, int numBytes)
+void readBytes (de::Socket& socket, vector<deUint8>& dst, size_t numBytes)
 {
-       int numRead = 0;
+       size_t numRead = 0;
        dst.resize(numBytes);
        while (numRead < numBytes)
        {
-               int                             numLeft         = numBytes - numRead;
-               int                             curNumRead      = 0;
+               size_t                  numLeft         = numBytes - numRead;
+               size_t                  curNumRead      = 0;
                deSocketResult  result          = socket.receive(&dst[numRead], numLeft, &curNumRead);
 
                if (result != DE_SOCKETRESULT_SUCCESS)
@@ -105,7 +105,7 @@ Message* readMessage (de::Socket& socket)
        readBytes(socket, header, MESSAGE_HEADER_SIZE);
 
        MessageType     type;
-       int                     messageSize;
+       size_t          messageSize;
        Message::parseHeader(&header[0], (int)header.size(), type, messageSize);
 
        // Simple messages without any data.
index 38b6120..5e47377 100644 (file)
@@ -73,11 +73,11 @@ void sendMessage (de::Socket& socket, const Message& message)
        message.write(buf);
 
        // Write to socket.
-       int pos = 0;
-       while (pos < (int)buf.size())
+       size_t pos = 0;
+       while (pos < buf.size())
        {
-               int                             numLeft         = (int)buf.size() - pos;
-               int                             numSent         = 0;
+               size_t                  numLeft         = buf.size() - pos;
+               size_t                  numSent         = 0;
                deSocketResult  result          = socket.send(&buf[pos], numLeft, &numSent);
 
                if (result != DE_SOCKETRESULT_SUCCESS)
@@ -87,14 +87,14 @@ void sendMessage (de::Socket& socket, const Message& message)
        }
 }
 
-void readBytes (de::Socket& socket, vector<deUint8>& dst, int numBytes)
+void readBytes (de::Socket& socket, vector<deUint8>& dst, size_t numBytes)
 {
-       int numRead = 0;
+       size_t numRead = 0;
        dst.resize(numBytes);
        while (numRead < numBytes)
        {
-               int                             numLeft         = numBytes - numRead;
-               int                             curNumRead      = 0;
+               size_t                  numLeft         = numBytes - numRead;
+               size_t                  curNumRead      = 0;
                deSocketResult  result          = socket.receive(&dst[numRead], numLeft, &curNumRead);
 
                if (result != DE_SOCKETRESULT_SUCCESS)
@@ -111,7 +111,7 @@ Message* readMessage (de::Socket& socket)
        readBytes(socket, header, MESSAGE_HEADER_SIZE);
 
        MessageType     type;
-       int                     messageSize;
+       size_t          messageSize;
        Message::parseHeader(&header[0], (int)header.size(), type, messageSize);
 
        // Simple messages without any data.
index 5a8a592..d99c805 100644 (file)
@@ -43,7 +43,7 @@ inline bool MessageBuilder::isComplete (void) const
        if (m_buffer.size() < MESSAGE_HEADER_SIZE)
                return false;
        else
-               return (int)m_buffer.size() == getMessageSize();
+               return m_buffer.size() == getMessageSize();
 }
 
 const deUint8* MessageBuilder::getMessageData (void) const
@@ -51,10 +51,10 @@ const deUint8* MessageBuilder::getMessageData (void) const
        return m_buffer.size() > MESSAGE_HEADER_SIZE ? &m_buffer[MESSAGE_HEADER_SIZE] : DE_NULL;
 }
 
-int MessageBuilder::getMessageDataSize (void) const
+size_t MessageBuilder::getMessageDataSize (void) const
 {
        DE_ASSERT(isComplete());
-       return (int)m_buffer.size() - MESSAGE_HEADER_SIZE;
+       return m_buffer.size() - MESSAGE_HEADER_SIZE;
 }
 
 void MessageBuilder::read (ByteBuffer& src)
@@ -78,15 +78,15 @@ void MessageBuilder::read (ByteBuffer& src)
        if (m_buffer.size() >= MESSAGE_HEADER_SIZE)
        {
                // We have header.
-               int msgSize                     = getMessageSize();
-               int numBytesLeft        = msgSize - (int)m_buffer.size();
-               int     numToRead               = de::min(src.getNumElements(), numBytesLeft);
+               size_t msgSize                  = getMessageSize();
+               size_t numBytesLeft             = msgSize - m_buffer.size();
+               size_t numToRead                = (size_t)de::min(src.getNumElements(), (int)numBytesLeft);
 
                if (numToRead > 0)
                {
                        int curBufPos = (int)m_buffer.size();
                        m_buffer.resize(curBufPos+numToRead);
-                       src.popBack(&m_buffer[curBufPos], numToRead);
+                       src.popBack(&m_buffer[curBufPos], (int)numToRead);
                }
        }
 }
@@ -257,7 +257,7 @@ void ExecutionRequestHandler::processSession (void)
        }
 }
 
-void ExecutionRequestHandler::processMessage (MessageType type, const deUint8* data, int dataSize)
+void ExecutionRequestHandler::processMessage (MessageType type, const deUint8* data, size_t dataSize)
 {
        switch (type)
        {
@@ -341,17 +341,17 @@ void ExecutionRequestHandler::pollKeepAlives (void)
 
 bool ExecutionRequestHandler::receive (void)
 {
-       int maxLen = de::min<int>((int)m_sendRecvTmpBuf.size(), m_bufferIn.getNumFree());
+       size_t maxLen = de::min(m_sendRecvTmpBuf.size(), (size_t)m_bufferIn.getNumFree());
 
        if (maxLen > 0)
        {
-               int                             numRecv;
+               size_t                  numRecv;
                deSocketResult  result  = m_socket->receive(&m_sendRecvTmpBuf[0], maxLen, &numRecv);
 
                if (result == DE_SOCKETRESULT_SUCCESS)
                {
                        DE_ASSERT(numRecv > 0);
-                       m_bufferIn.pushFront(&m_sendRecvTmpBuf[0], numRecv);
+                       m_bufferIn.pushFront(&m_sendRecvTmpBuf[0], (int)numRecv);
                        return true;
                }
                else if (result == DE_SOCKETRESULT_CONNECTION_CLOSED)
@@ -372,19 +372,19 @@ bool ExecutionRequestHandler::receive (void)
 
 bool ExecutionRequestHandler::send (void)
 {
-       int maxLen = de::min<int>((int)m_sendRecvTmpBuf.size(), m_bufferOut.getNumElements());
+       size_t maxLen = de::min(m_sendRecvTmpBuf.size(), (size_t)m_bufferOut.getNumElements());
 
        if (maxLen > 0)
        {
-               m_bufferOut.peekBack(&m_sendRecvTmpBuf[0], maxLen);
+               m_bufferOut.peekBack(&m_sendRecvTmpBuf[0], (int)maxLen);
 
-               int                             numSent;
+               size_t                  numSent;
                deSocketResult  result  = m_socket->send(&m_sendRecvTmpBuf[0], maxLen, &numSent);
 
                if (result == DE_SOCKETRESULT_SUCCESS)
                {
                        DE_ASSERT(numSent > 0);
-                       m_bufferOut.popBack(numSent);
+                       m_bufferOut.popBack((int)numSent);
                        return true;
                }
                else if (result == DE_SOCKETRESULT_CONNECTION_CLOSED)
index c9ad1ae..8e5cd8e 100644 (file)
@@ -72,14 +72,14 @@ public:
 
        bool                                    isComplete                      (void) const;
        MessageType                             getMessageType          (void) const    { return m_messageType; }
-       int                                             getMessageSize          (void) const    { return m_messageSize; }
+       size_t                                  getMessageSize          (void) const    { return m_messageSize; }
        const deUint8*                  getMessageData          (void) const;
-       int                                             getMessageDataSize      (void) const;
+       size_t                                  getMessageDataSize      (void) const;
 
 private:
        std::vector<deUint8>    m_buffer;
        MessageType                             m_messageType;
-       int                                             m_messageSize;
+       size_t                                  m_messageSize;
 };
 
 class ExecutionRequestHandler : public ConnectionHandler
@@ -96,7 +96,7 @@ private:
        ExecutionRequestHandler&        operator=                                               (const ExecutionRequestHandler& handler);
 
        void                                            processSession                                  (void);
-       void                                            processMessage                                  (MessageType type, const deUint8* data, int dataSize);
+       void                                            processMessage                                  (MessageType type, const deUint8* data, size_t dataSize);
 
        inline TestDriver*                      getTestDriver                                   (void) { if (!m_testDriver) acquireTestDriver(); return m_testDriver; }
        void                                            acquireTestDriver                               (void);
index e2471fa..53a1a35 100644 (file)
@@ -47,7 +47,7 @@ template <> int hostToNetwork (int value) { return (int)swapEndianess((deUint32)
 class MessageParser
 {
 public:
-       MessageParser (const deUint8* data, int dataSize)
+       MessageParser (const deUint8* data, size_t dataSize)
                : m_data        (data)
                , m_size        (dataSize)
                , m_pos         (0)
@@ -57,7 +57,7 @@ public:
        template <typename T>
        T get (void)
        {
-               XS_CHECK_MSG(m_pos + (int)sizeof(T) <= m_size, "Invalid payload size");
+               XS_CHECK_MSG(m_pos + sizeof(T) <= m_size, "Invalid payload size");
                T netValue;
                deMemcpy(&netValue, &m_data[m_pos], sizeof(T));
                m_pos += sizeof(T);
@@ -84,8 +84,8 @@ public:
 
 private:
        const deUint8*  m_data;
-       int                             m_size;
-       int                             m_pos;
+       size_t                  m_size;
+       size_t                  m_pos;
 };
 
 class MessageWriter
@@ -138,18 +138,18 @@ void MessageWriter::put<const char*> (const char* value)
        deMemcpy(&m_buf[curPos], &value[0], strLen+1);
 }
 
-void Message::parseHeader (const deUint8* data, int dataSize, MessageType& type, int& size)
+void Message::parseHeader (const deUint8* data, size_t dataSize, MessageType& type, size_t& size)
 {
        XS_CHECK_MSG(dataSize >= MESSAGE_HEADER_SIZE, "Incomplete header");
        MessageParser parser(data, dataSize);
-       size    = (MessageType)parser.get<int>();
+       size    = (size_t)(MessageType)parser.get<int>();
        type    = (MessageType)parser.get<int>();
 }
 
-void Message::writeHeader (MessageType type, int messageSize, deUint8* dst, int bufSize)
+void Message::writeHeader (MessageType type, size_t messageSize, deUint8* dst, size_t bufSize)
 {
        XS_CHECK_MSG(bufSize >= MESSAGE_HEADER_SIZE, "Incomplete header");
-       int netSize = hostToNetwork(messageSize);
+       int netSize = hostToNetwork((int)messageSize);
        int netType = hostToNetwork((int)type);
        deMemcpy(dst+0, &netSize, sizeof(netSize));
        deMemcpy(dst+4, &netType, sizeof(netType));
@@ -160,7 +160,7 @@ void Message::writeNoData (vector<deUint8>& buf) const
        MessageWriter writer(type, buf);
 }
 
-HelloMessage::HelloMessage (const deUint8* data, int dataSize)
+HelloMessage::HelloMessage (const deUint8* data, size_t dataSize)
        : Message(MESSAGETYPE_HELLO)
 {
        MessageParser parser(data, dataSize);
@@ -174,7 +174,7 @@ void HelloMessage::write (vector<deUint8>& buf) const
        writer.put(version);
 }
 
-TestMessage::TestMessage (const deUint8* data, int dataSize)
+TestMessage::TestMessage (const deUint8* data, size_t dataSize)
        : Message(MESSAGETYPE_TEST)
 {
        MessageParser parser(data, dataSize);
@@ -188,7 +188,7 @@ void TestMessage::write (vector<deUint8>& buf) const
        writer.put(test.c_str());
 }
 
-ExecuteBinaryMessage::ExecuteBinaryMessage (const deUint8* data, int dataSize)
+ExecuteBinaryMessage::ExecuteBinaryMessage (const deUint8* data, size_t dataSize)
        : Message(MESSAGETYPE_EXECUTE_BINARY)
 {
        MessageParser parser(data, dataSize);
@@ -208,7 +208,7 @@ void ExecuteBinaryMessage::write (vector<deUint8>& buf) const
        writer.put(caseList.c_str());
 }
 
-ProcessLogDataMessage::ProcessLogDataMessage (const deUint8* data, int dataSize)
+ProcessLogDataMessage::ProcessLogDataMessage (const deUint8* data, size_t dataSize)
        : Message(MESSAGETYPE_PROCESS_LOG_DATA)
 {
        MessageParser parser(data, dataSize);
@@ -222,7 +222,7 @@ void ProcessLogDataMessage::write (vector<deUint8>& buf) const
        writer.put(logData.c_str());
 }
 
-ProcessLaunchFailedMessage::ProcessLaunchFailedMessage (const deUint8* data, int dataSize)
+ProcessLaunchFailedMessage::ProcessLaunchFailedMessage (const deUint8* data, size_t dataSize)
        : Message(MESSAGETYPE_PROCESS_LAUNCH_FAILED)
 {
        MessageParser parser(data, dataSize);
@@ -236,7 +236,7 @@ void ProcessLaunchFailedMessage::write (vector<deUint8>& buf) const
        writer.put(reason.c_str());
 }
 
-ProcessFinishedMessage::ProcessFinishedMessage (const deUint8* data, int dataSize)
+ProcessFinishedMessage::ProcessFinishedMessage (const deUint8* data, size_t dataSize)
        : Message(MESSAGETYPE_PROCESS_FINISHED)
 {
        MessageParser parser(data, dataSize);
@@ -250,7 +250,7 @@ void ProcessFinishedMessage::write (vector<deUint8>& buf) const
        writer.put(exitCode);
 }
 
-InfoMessage::InfoMessage (const deUint8* data, int dataSize)
+InfoMessage::InfoMessage (const deUint8* data, size_t dataSize)
        : Message(MESSAGETYPE_INFO)
 {
        MessageParser parser(data, dataSize);
index 369ee92..e8ce3d2 100644 (file)
@@ -74,8 +74,8 @@ public:
 
        virtual void    write                   (std::vector<deUint8>& buf) const = DE_NULL;
 
-       static void             parseHeader             (const deUint8* data, int dataSize, MessageType& type, int& messageSize);
-       static void             writeHeader             (MessageType type, int messageSize, deUint8* dst, int bufSize);
+       static void             parseHeader             (const deUint8* data, size_t dataSize, MessageType& type, size_t& messageSize);
+       static void             writeHeader             (MessageType type, size_t messageSize, deUint8* dst, size_t bufSize);
 
 protected:
        void                    writeNoData             (std::vector<deUint8>& buf) const;
@@ -89,7 +89,7 @@ template <int MsgType>
 class SimpleMessage : public Message
 {
 public:
-                                       SimpleMessage   (const deUint8* data, int dataSize) : Message((MessageType)MsgType) { DE_UNREF(data); XS_CHECK_MSG(dataSize == 0, "No payload expected"); }
+                                       SimpleMessage   (const deUint8* data, size_t dataSize) : Message((MessageType)MsgType) { DE_UNREF(data); XS_CHECK_MSG(dataSize == 0, "No payload expected"); }
                                        SimpleMessage   (void) : Message((MessageType)MsgType) {}
                                        ~SimpleMessage  (void) {}
 
@@ -105,7 +105,7 @@ class HelloMessage : public Message
 public:
        int                             version;
 
-                                       HelloMessage    (const deUint8* data, int dataSize);
+                                       HelloMessage    (const deUint8* data, size_t dataSize);
                                        HelloMessage    (void) : Message(MESSAGETYPE_HELLO), version(PROTOCOL_VERSION) {}
                                        ~HelloMessage   (void) {}
 
@@ -120,7 +120,7 @@ public:
        std::string             workDir;
        std::string             caseList;
 
-                                       ExecuteBinaryMessage    (const deUint8* data, int dataSize);
+                                       ExecuteBinaryMessage    (const deUint8* data, size_t dataSize);
                                        ExecuteBinaryMessage    (void) : Message(MESSAGETYPE_EXECUTE_BINARY) {}
                                        ~ExecuteBinaryMessage   (void) {};
 
@@ -132,7 +132,7 @@ class ProcessLogDataMessage : public Message
 public:
        std::string             logData;
 
-                                       ProcessLogDataMessage           (const deUint8* data, int dataSize);
+                                       ProcessLogDataMessage           (const deUint8* data, size_t dataSize);
                                        ~ProcessLogDataMessage          (void) {}
 
        void                    write                                           (std::vector<deUint8>& buf) const;
@@ -143,7 +143,7 @@ class ProcessLaunchFailedMessage : public Message
 public:
        std::string             reason;
 
-                                       ProcessLaunchFailedMessage                      (const deUint8* data, int dataSize);
+                                       ProcessLaunchFailedMessage                      (const deUint8* data, size_t dataSize);
                                        ProcessLaunchFailedMessage                      (const char* reason_) : Message(MESSAGETYPE_PROCESS_LAUNCH_FAILED), reason(reason_) {}
                                        ~ProcessLaunchFailedMessage                     (void) {}
 
@@ -155,7 +155,7 @@ class ProcessFinishedMessage : public Message
 public:
        int                             exitCode;
 
-                                       ProcessFinishedMessage                  (const deUint8* data, int dataSize);
+                                       ProcessFinishedMessage                  (const deUint8* data, size_t dataSize);
                                        ProcessFinishedMessage                  (int exitCode_) : Message(MESSAGETYPE_PROCESS_FINISHED), exitCode(exitCode_) {}
                                        ~ProcessFinishedMessage                 (void) {}
 
@@ -167,7 +167,7 @@ class InfoMessage : public Message
 public:
        std::string             info;
 
-                                       InfoMessage                     (const deUint8* data, int dataSize);
+                                       InfoMessage                     (const deUint8* data, size_t dataSize);
                                        ~InfoMessage            (void) {}
 
        void                    write                           (std::vector<deUint8>& buf) const;
@@ -179,7 +179,7 @@ class TestMessage : public Message
 public:
        std::string             test;
 
-                                       TestMessage             (const deUint8* data, int dataSize);
+                                       TestMessage             (const deUint8* data, size_t dataSize);
                                        ~TestMessage    (void) {}
 
        void                    write                   (std::vector<deUint8>& buf) const;
index 46fe449..466b201 100644 (file)
@@ -353,7 +353,7 @@ void BatchExecutor::enqueueStateChanged (void* userPtr, CommLinkState state, con
        writer.enqueue();
 }
 
-void BatchExecutor::enqueueTestLogData (void* userPtr, const deUint8* bytes, int numBytes)
+void BatchExecutor::enqueueTestLogData (void* userPtr, const deUint8* bytes, size_t numBytes)
 {
        BatchExecutor*  executor        = static_cast<BatchExecutor*>(userPtr);
        CallWriter              writer          (&executor->m_dispatcher, BatchExecutor::dispatchTestLogData);
@@ -365,7 +365,7 @@ void BatchExecutor::enqueueTestLogData (void* userPtr, const deUint8* bytes, int
        writer.enqueue();
 }
 
-void BatchExecutor::enqueueInfoLogData (void* userPtr, const deUint8* bytes, int numBytes)
+void BatchExecutor::enqueueInfoLogData (void* userPtr, const deUint8* bytes, size_t numBytes)
 {
        BatchExecutor*  executor        = static_cast<BatchExecutor*>(userPtr);
        CallWriter              writer          (&executor->m_dispatcher, BatchExecutor::dispatchInfoLogData);
index 509bbb0..fae8115 100644 (file)
@@ -87,8 +87,8 @@ private:
 
        // Callbacks for CommLink.
        static void                             enqueueStateChanged     (void* userPtr, CommLinkState state, const char* message);
-       static void                             enqueueTestLogData      (void* userPtr, const deUint8* bytes, int numBytes);
-       static void                             enqueueInfoLogData      (void* userPtr, const deUint8* bytes, int numBytes);
+       static void                             enqueueTestLogData      (void* userPtr, const deUint8* bytes, size_t numBytes);
+       static void                             enqueueInfoLogData      (void* userPtr, const deUint8* bytes, size_t numBytes);
 
        // Called in CallQueue dispatch.
        static void                             dispatchStateChanged    (CallReader data);
index 7f87b54..e9da0d6 100644 (file)
@@ -160,14 +160,14 @@ CallReader::CallReader (Call* call)
 {
 }
 
-void CallReader::read (deUint8* bytes, int numBytes)
+void CallReader::read (deUint8* bytes, size_t numBytes)
 {
        DE_ASSERT(m_curPos + numBytes <= m_call->getDataSize());
        deMemcpy(bytes, m_call->getData()+m_curPos, numBytes);
        m_curPos += numBytes;
 }
 
-const deUint8* CallReader::getDataBlock (int numBytes)
+const deUint8* CallReader::getDataBlock (size_t numBytes)
 {
        DE_ASSERT(m_curPos + numBytes <= m_call->getDataSize());
 
@@ -209,10 +209,10 @@ CallWriter::~CallWriter (void)
                m_queue->freeCall(m_call);
 }
 
-void CallWriter::write (const deUint8* bytes, int numBytes)
+void CallWriter::write (const deUint8* bytes, size_t numBytes)
 {
        DE_ASSERT(!m_enqueued);
-       int curPos = m_call->getDataSize();
+       size_t curPos = m_call->getDataSize();
        m_call->setDataSize(curPos+numBytes);
        deMemcpy(m_call->getData()+curPos, bytes, numBytes);
 }
index 3d72655..9bbdd54 100644 (file)
@@ -55,8 +55,8 @@ public:
        Function                                        getFunction                     (void) const    { return m_func;                                }
        void                                            setFunction                     (Function func) { m_func = func;                                }
 
-       int                                                     getDataSize                     (void) const    { return (int)m_data.size();    }
-       void                                            setDataSize                     (int size)              { m_data.resize(size);                  }
+       size_t                                          getDataSize                     (void) const    { return m_data.size();                 }
+       void                                            setDataSize                     (size_t size)   { m_data.resize(size);                  }
 
        const deUint8*                          getData                         (void) const    { return m_data.empty() ? DE_NULL : &m_data[0]; }
        deUint8*                                        getData                         (void)                  { return m_data.empty() ? DE_NULL : &m_data[0]; }
@@ -72,12 +72,12 @@ public:
                                        CallReader                      (Call* call);
                                        CallReader                      (void) : m_call(DE_NULL), m_curPos(0) {}
 
-       void                    read                            (deUint8* bytes, int numBytes);
-       const deUint8*  getDataBlock            (int numBytes);                                 //!< \note Valid only during call.
+       void                    read                            (deUint8* bytes, size_t numBytes);
+       const deUint8*  getDataBlock            (size_t numBytes);                                      //!< \note Valid only during call.
 
 private:
        Call*                   m_call;
-       int                             m_curPos;
+       size_t                  m_curPos;
 };
 
 class CallWriter
@@ -86,7 +86,7 @@ public:
                                        CallWriter                      (CallQueue* queue, Call::Function function);
                                        ~CallWriter                     (void);
 
-       void                    write                           (const deUint8* bytes, int numBytes);
+       void                    write                           (const deUint8* bytes, size_t numBytes);
        void                    enqueue                         (void);
 
 private:
index 66c314d..c4fedef 100644 (file)
@@ -48,7 +48,7 @@ class CommLink
 {
 public:
        typedef void (*StateChangedFunc)        (void* userPtr, CommLinkState state, const char* message);
-       typedef void (*LogDataFunc)                     (void* userPtr, const deUint8* bytes, int numBytes);
+       typedef void (*LogDataFunc)                     (void* userPtr, const deUint8* bytes, size_t numBytes);
 
                                                                CommLink                                (void);
        virtual                                         ~CommLink                               (void);
index 1778a4f..651d199 100644 (file)
@@ -133,7 +133,7 @@ void TcpIpLinkState::setState (CommLinkState state, const char* error)
                callback(userPtr, state, error);
 }
 
-void TcpIpLinkState::onTestLogData (const deUint8* bytes, int numBytes) const
+void TcpIpLinkState::onTestLogData (const deUint8* bytes, size_t numBytes) const
 {
        CommLink::LogDataFunc   callback        = DE_NULL;
        void*                                   userPtr         = DE_NULL;
@@ -147,7 +147,7 @@ void TcpIpLinkState::onTestLogData (const deUint8* bytes, int numBytes) const
                callback(userPtr, bytes, numBytes);
 }
 
-void TcpIpLinkState::onInfoLogData (const deUint8* bytes, int numBytes) const
+void TcpIpLinkState::onInfoLogData (const deUint8* bytes, size_t numBytes) const
 {
        CommLink::LogDataFunc   callback        = DE_NULL;
        void*                                   userPtr         = DE_NULL;
@@ -206,8 +206,8 @@ void TcpIpSendThread::run (void)
 
                while (!m_buffer.isCanceled())
                {
-                       int                             numToSend       = 0;
-                       int                             numSent         = 0;
+                       size_t                  numToSend       = 0;
+                       size_t                  numSent         = 0;
                        deSocketResult  result          = DE_SOCKETRESULT_LAST;
 
                        try
@@ -234,7 +234,7 @@ void TcpIpSendThread::run (void)
                                else if (result == DE_SOCKETRESULT_WOULD_BLOCK)
                                {
                                        // \note Socket should not be in non-blocking mode.
-                                       DE_ASSERT(numSent <= 0);
+                                       DE_ASSERT(numSent == 0);
                                        deYield();
                                }
                                else
@@ -291,7 +291,7 @@ void TcpIpRecvThread::run (void)
                {
                        bool                            hasHeader               = m_curMsgPos >= xs::MESSAGE_HEADER_SIZE;
                        bool                            hasPayload              = false;
-                       int                                     messageSize             = 0;
+                       size_t                          messageSize             = 0;
                        xs::MessageType         messageType             = (xs::MessageType)0;
 
                        if (hasHeader)
@@ -309,12 +309,12 @@ void TcpIpRecvThread::run (void)
                        else
                        {
                                // Try to receive missing bytes.
-                               int                                     curSize                 = hasHeader ? messageSize : xs::MESSAGE_HEADER_SIZE;
-                               int                                     bytesToRecv             = curSize-m_curMsgPos;
-                               int                                     numRecv                 = 0;
+                               size_t                          curSize                 = hasHeader ? messageSize : (size_t)xs::MESSAGE_HEADER_SIZE;
+                               size_t                          bytesToRecv             = curSize-m_curMsgPos;
+                               size_t                          numRecv                 = 0;
                                deSocketResult          result                  = DE_SOCKETRESULT_LAST;
 
-                               if ((int)m_curMsgBuf.size() < curSize)
+                               if (m_curMsgBuf.size() < curSize)
                                        m_curMsgBuf.resize(curSize);
 
                                result = m_socket.receive(&m_curMsgBuf[m_curMsgPos], bytesToRecv, &numRecv);
@@ -328,7 +328,7 @@ void TcpIpRecvThread::run (void)
                                else if (result == DE_SOCKETRESULT_WOULD_BLOCK)
                                {
                                        // \note Socket should not be in non-blocking mode.
-                                       DE_ASSERT(numRecv <= 0);
+                                       DE_ASSERT(numRecv == 0);
                                        deYield();
                                }
                                else
@@ -359,7 +359,7 @@ void TcpIpRecvThread::stop (void)
        }
 }
 
-void TcpIpRecvThread::handleMessage (xs::MessageType messageType, const deUint8* data, int dataSize)
+void TcpIpRecvThread::handleMessage (xs::MessageType messageType, const deUint8* data, size_t dataSize)
 {
        switch (messageType)
        {
index d401355..51ca7c3 100644 (file)
@@ -49,8 +49,8 @@ public:
        void                                            setCallbacks                            (CommLink::StateChangedFunc stateChangedCallback, CommLink::LogDataFunc testLogDataCallback, CommLink::LogDataFunc infoLogDataCallback, void* userPtr);
 
        void                                            setState                                        (CommLinkState state, const char* error = "");
-       void                                            onTestLogData                           (const deUint8* bytes, int numBytes) const;
-       void                                            onInfoLogData                           (const deUint8* bytes, int numBytes) const;
+       void                                            onTestLogData                           (const deUint8* bytes, size_t numBytes) const;
+       void                                            onInfoLogData                           (const deUint8* bytes, size_t numBytes) const;
 
        void                                            onKeepaliveReceived                     (void);
        deUint64                                        getLastKeepaliveRecevied        (void) const;
@@ -104,13 +104,13 @@ public:
        bool                                            isRunning                               (void) const { return m_isRunning; }
 
 private:
-       void                                            handleMessage                   (xs::MessageType messageType, const deUint8* data, int dataSize);
+       void                                            handleMessage                   (xs::MessageType messageType, const deUint8* data, size_t dataSize);
 
        de::Socket&                                     m_socket;
        TcpIpLinkState&                         m_state;
 
        std::vector<deUint8>            m_curMsgBuf;
-       int                                                     m_curMsgPos;
+       size_t                                          m_curMsgPos;
 
        bool                                            m_isRunning;
 };
index 1c7072a..0b95b8e 100644 (file)
@@ -802,11 +802,11 @@ void TestResultParser::handleData (void)
                                deUint8         decodedBits     = 0;
 
                                if (de::inRange<deInt8>(byte, 'A', 'Z'))
-                                       decodedBits = byte - 'A';
+                                       decodedBits = (deUint8)(byte - 'A');
                                else if (de::inRange<deInt8>(byte, 'a', 'z'))
-                                       decodedBits = ('Z'-'A'+1) + (byte-'a');
+                                       decodedBits = (deUint8)(('Z'-'A'+1) + (byte-'a'));
                                else if (de::inRange<deInt8>(byte, '0', '9'))
-                                       decodedBits = ('Z'-'A'+1) + ('z'-'a'+1) + (byte-'0');
+                                       decodedBits = (deUint8)(('Z'-'A'+1) + ('z'-'a'+1) + (byte-'0'));
                                else if (byte == '+')
                                        decodedBits = ('Z'-'A'+1) + ('z'-'a'+1) + ('9'-'0'+1);
                                else if (byte == '/')
@@ -833,10 +833,10 @@ void TestResultParser::handleData (void)
 
                                switch (phase)
                                {
-                                       case 0: outPtr[0] |= decodedBits<<2;                                                                                    break;
-                                       case 1: outPtr[0] |= (decodedBits>>4);  outPtr[1] |= ((decodedBits&0xF)<<4);    break;
-                                       case 2: outPtr[1] |= (decodedBits>>2);  outPtr[2] |= ((decodedBits&0x3)<<6);    break;
-                                       case 3: outPtr[2] |= decodedBits;                                                                                               break;
+                                       case 0: outPtr[0] |= (deUint8)(decodedBits<<2);                                                                                                 break;
+                                       case 1: outPtr[0] |= (deUint8)(decodedBits>>4); outPtr[1] |= (deUint8)((decodedBits&0xF)<<4);   break;
+                                       case 2: outPtr[1] |= (deUint8)(decodedBits>>2); outPtr[2] |= (deUint8)((decodedBits&0x3)<<6);   break;
+                                       case 3: outPtr[2] |= decodedBits;                                                                                                                               break;
                                        default:
                                                DE_ASSERT(false);
                                }
index 69cf477..7e00594 100644 (file)
@@ -50,8 +50,8 @@ struct Message
        {
        }
 
-       deUint16 getThreadId    (void) const { return data >> 16;               }
-       deUint16 getPayload             (void) const { return data & 0xffff;    }
+       deUint16 getThreadId    (void) const { return (deUint16)(data >> 16);           }
+       deUint16 getPayload             (void) const { return (deUint16)(data & 0xffff);        }
 };
 
 typedef BlockBuffer<Message> MessageBuffer;
@@ -208,7 +208,7 @@ void runTest (void)
                {
                        deUint32 cmpSum = 0;
                        for (int j = 0; j < numConsumers; j++)
-                               cmpSum += consumers[j]->getPayloadSum(i);
+                               cmpSum += consumers[j]->getPayloadSum((deUint16)i);
                        DE_TEST_ASSERT(refSum == cmpSum);
                }
 
index 9a1db24..cec9acd 100644 (file)
@@ -48,7 +48,7 @@ class PoolArrayIterator;
  *       to access next element(s) doesn't work.
  * \todo [2013-02-11 pyry] Make elements per page template argument.
  *//*--------------------------------------------------------------------*/
-template<typename T, deUint32 Alignment = (sizeof(T) > 4 ? 4 : sizeof(T))>
+template<typename T, deUint32 Alignment = (sizeof(T) > 4 ? 4 : (deUint32)sizeof(T))>
 class PoolArray
 {
 public:
index f8198ff..e401605 100644 (file)
@@ -95,8 +95,8 @@ public:
 
        void                            close                           (void);
 
-       deSocketResult          send                            (const void* buf, int bufSize, int* numSent)    { return deSocket_send(m_socket, buf, bufSize, numSent);        }
-       deSocketResult          receive                         (void* buf, int bufSize, int* numRecv)                  { return deSocket_receive(m_socket, buf, bufSize, numRecv);     }
+       deSocketResult          send                            (const void* buf, size_t bufSize, size_t* numSent)      { return deSocket_send(m_socket, buf, bufSize, numSent);        }
+       deSocketResult          receive                         (void* buf, size_t bufSize, size_t* numRecv)            { return deSocket_receive(m_socket, buf, bufSize, numRecv);     }
 
 private:
                                                Socket                          (deSocket* socket) : m_socket(socket) {}
index 065688b..3a8030d 100644 (file)
@@ -49,8 +49,8 @@ struct Message
        {
        }
 
-       deUint16 getThreadId    (void) const { return data >> 16;               }
-       deUint16 getPayload             (void) const { return data & 0xffff;    }
+       deUint16 getThreadId    (void) const { return (deUint16)(data >> 16);           }
+       deUint16 getPayload             (void) const { return (deUint16)(data & 0xffff);        }
 };
 
 class Consumer : public Thread
@@ -169,7 +169,7 @@ void ThreadSafeRingBuffer_selfTest (void)
                {
                        deUint32 cmpSum = 0;
                        for (int j = 0; j < numConsumers; j++)
-                               cmpSum += consumers[j]->getPayloadSum(i);
+                               cmpSum += consumers[j]->getPayloadSum((deUint16)i);
                        DE_TEST_ASSERT(refSum == cmpSum);
                }
 
index 44f61f4..d0ebb1c 100644 (file)
@@ -56,7 +56,7 @@ deCommandLine* deCommandLine_parse (const char* commandLine)
        DE_ASSERT(commandLine);
 
        /* Create buffer for args (no expansion can happen). */
-       buf             = (char*)deCalloc((int)strlen(commandLine)+1);
+       buf             = (char*)deCalloc(strlen(commandLine)+1);
        pos             = 0;
        argNdx  = 0;
        outPtr  = buf;
@@ -118,7 +118,7 @@ deCommandLine* deCommandLine_parse (const char* commandLine)
        {
                deCommandLine* cmdLine = (deCommandLine*)deCalloc(sizeof(deCommandLine));
 
-               if (!cmdLine || !(cmdLine->args = (char**)deCalloc(sizeof(char*)*CharPtrArray_getNumElements(args))))
+               if (!cmdLine || !(cmdLine->args = (char**)deCalloc(sizeof(char*)*(size_t)CharPtrArray_getNumElements(args))))
                {
                        deFree(cmdLine);
                        deFree(buf);
index 9cc2bf8..1ca81d6 100644 (file)
@@ -185,7 +185,7 @@ static deFileResult mapReadWriteResult (deInt64 numBytes)
 
 deFileResult deFile_read (deFile* file, void* buf, deInt64 bufSize, deInt64* numReadPtr)
 {
-       deInt64 numRead = read(file->fd, buf, bufSize);
+       deInt64 numRead = read(file->fd, buf, (size_t)bufSize);
 
        if (numReadPtr)
                *numReadPtr = numRead;
@@ -195,7 +195,7 @@ deFileResult deFile_read (deFile* file, void* buf, deInt64 bufSize, deInt64* num
 
 deFileResult deFile_write (deFile* file, const void* buf, deInt64 bufSize, deInt64* numWrittenPtr)
 {
-       deInt64 numWritten = write(file->fd, buf, bufSize);
+       deInt64 numWritten = write(file->fd, buf, (size_t)bufSize);
 
        if (numWrittenPtr)
                *numWrittenPtr = numWritten;
index 1b7ed5d..2962a1a 100644 (file)
@@ -60,8 +60,9 @@ struct deProcess_s
 
 static void die (int statusPipe, const char* message)
 {
-       int msgLen = strlen(message);
-       int res = 0;
+       size_t  msgLen  = strlen(message);
+       int             res             = 0;
+
        printf("Process launch failed: %s\n", message);
        res = (int)write(statusPipe, message, msgLen+1);
        DE_UNREF(res); /* No need to check result. */
@@ -78,7 +79,7 @@ static void dieLastError (int statusPipe, const char* message)
 
 DE_INLINE deBool beginsWithPath (const char* fileName, const char* pathPrefix)
 {
-       int pathLen = strlen(pathPrefix);
+       size_t pathLen = strlen(pathPrefix);
 
        /* Strip trailing / */
        while (pathLen > 0 && pathPrefix[pathLen-1] == '/')
@@ -89,8 +90,8 @@ DE_INLINE deBool beginsWithPath (const char* fileName, const char* pathPrefix)
 
 static void stripLeadingPath (char* fileName, const char* pathPrefix)
 {
-       int pathLen             = strlen(pathPrefix);
-       int fileNameLen = strlen(fileName);
+       size_t pathLen          = strlen(pathPrefix);
+       size_t fileNameLen      = strlen(fileName);
 
        DE_ASSERT(beginsWithPath(fileName, pathPrefix));
 
@@ -108,7 +109,7 @@ static void stripLeadingPath (char* fileName, const char* pathPrefix)
 static void execProcess (const char* commandLine, const char* workingDirectory, int statusPipe)
 {
        deCommandLine*  cmdLine         = deCommandLine_parse(commandLine);
-       char**                  argList         = cmdLine ? (char**)deCalloc(sizeof(char*)*(cmdLine->numArgs+1)) : DE_NULL;
+       char**                  argList         = cmdLine ? (char**)deCalloc(sizeof(char*)*((size_t)cmdLine->numArgs+1)) : DE_NULL;
 
        if (!cmdLine || !argList)
                die(statusPipe, "Command line parsing failed (out of memory)");
@@ -299,7 +300,7 @@ deBool deProcess_start (deProcess* process, const char* commandLine, const char*
                /* Check status. */
                {
                        char    errBuf[256];
-                       int             result  = 0;
+                       ssize_t result = 0;
 
                        close(statusPipe[1]);
                        while ((result = read(statusPipe[0], errBuf, 1)) == -1)
@@ -307,6 +308,8 @@ deBool deProcess_start (deProcess* process, const char* commandLine, const char*
 
                        if (result > 0)
                        {
+                               int procStatus = 0;
+
                                /* Read full error msg. */
                                int errPos = 1;
                                while (errPos < DE_LENGTH_OF_ARRAY(errBuf))
@@ -328,7 +331,7 @@ deBool deProcess_start (deProcess* process, const char* commandLine, const char*
                                closePipe(pipeErr);
 
                                /* Run waitpid to clean up zombie. */
-                               waitpid(pid, &result, 0);
+                               waitpid(pid, &procStatus, 0);
 
                                deProcess_setError(process, errBuf);
 
@@ -348,9 +351,9 @@ deBool deProcess_start (deProcess* process, const char* commandLine, const char*
                close(pipeOut[1]);
                close(pipeErr[1]);
 
-               process->standardIn             = deFile_createFromHandle(pipeIn[1]);
-               process->standardOut    = deFile_createFromHandle(pipeOut[0]);
-               process->standardErr    = deFile_createFromHandle(pipeErr[0]);
+               process->standardIn             = deFile_createFromHandle((deUintptr)pipeIn[1]);
+               process->standardOut    = deFile_createFromHandle((deUintptr)pipeOut[0]);
+               process->standardErr    = deFile_createFromHandle((deUintptr)pipeErr[0]);
 
                if (!process->standardIn)
                        close(pipeIn[1]);
index fa8eced..78e1c4d 100644 (file)
@@ -189,9 +189,13 @@ static deBool initWinsock (void)
 #if defined(DE_USE_WINSOCK)
        /* \note SOCKET is unsigned type! */
        typedef SOCKET                                  deSocketHandle;
+       typedef int                                             NativeSocklen;
+       typedef int                                             NativeSize;
 #      define DE_INVALID_SOCKET_HANDLE INVALID_SOCKET
 #else
        typedef int                                             deSocketHandle;
+       typedef socklen_t                               NativeSocklen;
+       typedef size_t                                  NativeSize;
 #      define DE_INVALID_SOCKET_HANDLE -1
 #endif
 
@@ -251,7 +255,7 @@ static int deSocketProtocolToBsdProtocol (deSocketProtocol protocol)
        }
 }
 
-static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, int bsdAddrBufSize, struct sockaddr* bsdAddr, int* bsdAddrLen)
+static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, size_t bsdAddrBufSize, struct sockaddr* bsdAddr, NativeSocklen* bsdAddrLen)
 {
        deMemset(bsdAddr, 0, bsdAddrBufSize);
 
@@ -275,28 +279,28 @@ static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, int b
 
                /* \note Always uses first address. */
 
-               if (bsdAddrBufSize < (int)result->ai_addrlen)
+               if (bsdAddrBufSize < (size_t)result->ai_addrlen)
                {
                        DE_ASSERT(!"Too small bsdAddr buffer");
                        freeaddrinfo(result);
                        return DE_FALSE;
                }
 
-               *bsdAddrLen     = (int)result->ai_addrlen;
+               *bsdAddrLen     = (NativeSocklen)result->ai_addrlen;
 
-               deMemcpy(bsdAddr, result->ai_addr, (int)result->ai_addrlen);
+               deMemcpy(bsdAddr, result->ai_addr, (size_t)result->ai_addrlen);
                freeaddrinfo(result);
 
                /* Add port. */
                if (bsdAddr->sa_family == AF_INET)
                {
-                       if (*bsdAddrLen < (int)sizeof(struct sockaddr_in))
+                       if (*bsdAddrLen < (NativeSocklen)sizeof(struct sockaddr_in))
                                return DE_FALSE;
                        ((struct sockaddr_in*)bsdAddr)->sin_port = htons((deUint16)address->port);
                }
                else if (bsdAddr->sa_family == AF_INET6)
                {
-                       if (*bsdAddrLen < (int)sizeof(struct sockaddr_in6))
+                       if (*bsdAddrLen < (NativeSocklen)sizeof(struct sockaddr_in6))
                                return DE_FALSE;
                        ((struct sockaddr_in6*)bsdAddr)->sin6_port = htons((deUint16)address->port);
                }
@@ -309,7 +313,7 @@ static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, int b
        {
                struct sockaddr_in* addr4 = (struct sockaddr_in*)bsdAddr;
 
-               if (bsdAddrBufSize < (int)sizeof(struct sockaddr_in))
+               if (bsdAddrBufSize < sizeof(struct sockaddr_in))
                {
                        DE_ASSERT(!"Too small bsdAddr buffer");
                        return DE_FALSE;
@@ -319,7 +323,7 @@ static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, int b
                addr4->sin_family               = AF_INET;
                addr4->sin_addr.s_addr  = INADDR_ANY;
 
-               *bsdAddrLen     = sizeof(struct sockaddr_in);
+               *bsdAddrLen     = (NativeSocklen)sizeof(struct sockaddr_in);
 
                return DE_TRUE;
        }
@@ -327,7 +331,7 @@ static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, int b
        {
                struct sockaddr_in6* addr6 = (struct sockaddr_in6*)bsdAddr;
 
-               if (bsdAddrBufSize < (int)sizeof(struct sockaddr_in6))
+               if (bsdAddrBufSize < sizeof(struct sockaddr_in6))
                {
                        DE_ASSERT(!"Too small bsdAddr buffer");
                        return DE_FALSE;
@@ -336,7 +340,7 @@ static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, int b
                addr6->sin6_port        = htons((deUint16)address->port);
                addr6->sin6_family      = AF_INET6;
 
-               *bsdAddrLen     = sizeof(struct sockaddr_in6);
+               *bsdAddrLen     = (NativeSocklen)sizeof(struct sockaddr_in6);
 
                return DE_TRUE;
        }
@@ -472,13 +476,13 @@ deBool deSocket_listen (deSocket* sock, const deSocketAddress* address)
        const int                       backlogSize     = 4;
        deUint8                         bsdAddrBuf[sizeof(struct sockaddr_in6)];
        struct sockaddr*        bsdAddr         = (struct sockaddr*)&bsdAddrBuf[0];
-       int                                     bsdAddrLen;
+       NativeSocklen           bsdAddrLen;
 
        if (sock->state != DE_SOCKETSTATE_CLOSED)
                return DE_FALSE;
 
        /* Resolve address. */
-       if (!deSocketAddressToBsdAddress(address, (int)sizeof(bsdAddrBuf), bsdAddr, &bsdAddrLen))
+       if (!deSocketAddressToBsdAddress(address, sizeof(bsdAddrBuf), bsdAddr, &bsdAddrLen))
                return DE_FALSE;
 
        /* Create socket. */
@@ -495,7 +499,7 @@ deBool deSocket_listen (deSocket* sock, const deSocketAddress* address)
        }
 
        /* Bind to address. */
-       if (bind(sock->handle, bsdAddr, bsdAddrLen) != 0)
+       if (bind(sock->handle, bsdAddr, (NativeSocklen)bsdAddrLen) != 0)
        {
                deSocket_close(sock);
                return DE_FALSE;
@@ -519,19 +523,11 @@ deSocket* deSocket_accept (deSocket* sock, deSocketAddress* clientAddress)
        deSocket*                       newSock         = DE_NULL;
        deUint8                         bsdAddrBuf[sizeof(struct sockaddr_in6)];
        struct sockaddr*        bsdAddr         = (struct sockaddr*)&bsdAddrBuf[0];
-#if defined(DE_USE_WINSOCK)
-       int                                     bsdAddrLen      = (int)sizeof(bsdAddrBuf);
-#else
-       socklen_t                       bsdAddrLen      = (socklen_t)sizeof(bsdAddrBuf);
-#endif
+       NativeSocklen           bsdAddrLen      = (NativeSocklen)sizeof(bsdAddrBuf);
 
-       deMemset(bsdAddr, 0, (int)bsdAddrLen);
+       deMemset(bsdAddr, 0, (size_t)bsdAddrLen);
 
-#if defined(DE_USE_WINSOCK)
        newFd = accept(sock->handle, bsdAddr, &bsdAddrLen);
-#else
-       newFd = accept(sock->handle, bsdAddr, (socklen_t*)&bsdAddrLen);
-#endif
        if (!deSocketHandleIsValid(newFd))
                return DE_NULL;
 
@@ -561,10 +557,10 @@ deBool deSocket_connect (deSocket* sock, const deSocketAddress* address)
 {
        deUint8                         bsdAddrBuf[sizeof(struct sockaddr_in6)];
        struct sockaddr*        bsdAddr         = (struct sockaddr*)&bsdAddrBuf[0];
-       int                                     bsdAddrLen;
+       NativeSocklen           bsdAddrLen;
 
        /* Resolve address. */
-       if (!deSocketAddressToBsdAddress(address, (int)sizeof(bsdAddrBuf), bsdAddr, &bsdAddrLen))
+       if (!deSocketAddressToBsdAddress(address, sizeof(bsdAddrBuf), bsdAddr, &bsdAddrLen))
                return DE_FALSE;
 
        /* Create socket. */
@@ -751,13 +747,13 @@ DE_INLINE void deSocket_setChannelsClosed (deSocket* sock, deUint32 channels)
        deMutex_unlock(sock->stateLock);
 }
 
-deSocketResult deSocket_send (deSocket* sock, const void* buf, int bufSize, int* numSentPtr)
+deSocketResult deSocket_send (deSocket* sock, const void* buf, size_t bufSize, size_t* numSentPtr)
 {
-       int                             numSent = (int)send(sock->handle, (const char*)buf, bufSize, 0);
+       int                             numSent = (int)send(sock->handle, (const char*)buf, (NativeSize)bufSize, 0);
        deSocketResult  result  = mapSendRecvResult(numSent);
 
        if (numSentPtr)
-               *numSentPtr = numSent;
+               *numSentPtr = (numSent > 0) ? ((size_t)numSent) : (0);
 
        /* Update state. */
        if (result == DE_SOCKETRESULT_CONNECTION_CLOSED)
@@ -768,13 +764,13 @@ deSocketResult deSocket_send (deSocket* sock, const void* buf, int bufSize, int*
        return result;
 }
 
-deSocketResult deSocket_receive (deSocket* sock, void* buf, int bufSize, int* numReceivedPtr)
+deSocketResult deSocket_receive (deSocket* sock, void* buf, size_t bufSize, size_t* numReceivedPtr)
 {
-       int                             numRecv = (int)recv(sock->handle, (char*)buf, bufSize, 0);
+       int                             numRecv = (int)recv(sock->handle, (char*)buf, (NativeSize)bufSize, 0);
        deSocketResult  result  = mapSendRecvResult(numRecv);
 
        if (numReceivedPtr)
-               *numReceivedPtr = numRecv;
+               *numReceivedPtr = (numRecv > 0) ? ((size_t)numRecv) : (0);
 
        /* Update state. */
        if (result == DE_SOCKETRESULT_CONNECTION_CLOSED)
index 6270630..78d9b23 100644 (file)
@@ -131,8 +131,8 @@ deBool                              deSocket_connect                        (deSocket* socket, const deSocketAddress* address);
 deBool                         deSocket_shutdown                       (deSocket* socket, deUint32 channels);
 deBool                         deSocket_close                          (deSocket* socket);
 
-deSocketResult         deSocket_send                           (deSocket* socket, const void* buf, int bufSize, int* numSent);
-deSocketResult         deSocket_receive                        (deSocket* socket, void* buf, int bufSize, int* numReceived);
+deSocketResult         deSocket_send                           (deSocket* socket, const void* buf, size_t bufSize, size_t* numSent);
+deSocketResult         deSocket_receive                        (deSocket* socket, void* buf, size_t bufSize, size_t* numReceived);
 
 /* Utilities. */
 
index 0d39d82..15ec454 100644 (file)
@@ -68,9 +68,9 @@ void deTimer_selfTest (void)
 
                DE_TEST_ASSERT(scheduleOk);
 
-               deSleep(interval*intervalSleepMultiplier);
+               deSleep((deUint32)(interval*intervalSleepMultiplier));
                deTimer_disable(timer);
-               deSleep(interval);
+               deSleep((deUint32)interval);
 
                printf("  timer fired %d times, expected %d\n", numCalls, expectedCalls);
                DE_TEST_ASSERT(!isSingle || numCalls == 1);