Commit 91153194 authored by Jacob Sologub's avatar Jacob Sologub Committed by Alex Hultman

Fixing implicit conversion warnings. (#752)

* Fixing implicit conversion warnings.

* Fixing missing parenthesis mistake in WebSocketProtocol and Networking.

fef1ee5
parent f01f5991
......@@ -21,12 +21,12 @@ char *getHeaders(char *buffer, char *end, Header *headers, size_t maxHeaders) {
return nullptr;
}
} else {
headers->keyLength = buffer - headers->key;
headers->keyLength = (unsigned int) (buffer - headers->key);
for (buffer++; (*buffer == ':' || *buffer < 33) && *buffer != '\r'; buffer++);
headers->value = buffer;
buffer = (char *) memchr(buffer, '\r', end - buffer); //for (; *buffer != '\r'; buffer++);
if (buffer /*!= end*/ && buffer[1] == '\n') {
headers->valueLength = buffer - headers->value;
headers->valueLength = (unsigned int) (buffer - headers->value);
buffer += 2;
headers++;
} else {
......@@ -140,7 +140,7 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt
Header contentLength;
if (req.getMethod() != HttpMethod::METHOD_GET && (contentLength = req.getHeader("content-length", 14))) {
httpSocket->contentLength = atoi(contentLength.value);
size_t bytesToRead = std::min<int>(httpSocket->contentLength, end - cursor);
size_t bytesToRead = std::min<size_t>(httpSocket->contentLength, end - cursor);
Group<SERVER>::from(httpSocket)->httpRequestHandler(res, req, cursor, bytesToRead, httpSocket->contentLength -= bytesToRead);
cursor += bytesToRead;
} else {
......@@ -169,7 +169,7 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt
webSocket->cork(true);
Group<isServer>::from(webSocket)->connectionHandler(webSocket, req);
if (!(webSocket->isClosed() || webSocket->isShuttingDown())) {
WebSocketProtocol<isServer, WebSocket<isServer>>::consume(cursor, end - cursor, webSocket);
WebSocketProtocol<isServer, WebSocket<isServer>>::consume(cursor, (unsigned int) (end - cursor), webSocket);
}
webSocket->cork(false);
delete httpSocket;
......
......@@ -8,7 +8,7 @@ char *Hub::inflate(char *data, size_t &length, size_t maxPayload) {
dynamicInflationBuffer.clear();
inflationStream.next_in = (Bytef *) data;
inflationStream.avail_in = length;
inflationStream.avail_in = (unsigned int) length;
int err;
do {
......
......@@ -164,7 +164,7 @@ private:
static int passwordCallback(char *buf, int size, int rwflag, void *u)
{
std::string *password = (std::string *) u;
int length = std::min<int>(size, password->length());
int length = std::min<int>(size, (int) password->length());
memcpy(buf, password->data(), length);
buf[length] = '\0';
return length;
......@@ -216,7 +216,7 @@ struct WIN32_EXPORT NodeData {
static void asyncCallback(Async *async);
static int getMemoryBlockIndex(size_t length) {
return (length >> 4) + bool(length & 15);
return (int) ((length >> 4) + bool(length & 15));
}
char *getSmallMemoryBlock(int index) {
......
......@@ -154,7 +154,7 @@ protected:
socket->cork(true);
while (true) {
Queue::Message *messagePtr = socket->messageQueue.front();
int sent = SSL_write(socket->ssl, messagePtr->data, messagePtr->length);
int sent = SSL_write(socket->ssl, messagePtr->data, (int) messagePtr->length);
if (sent == (ssize_t) messagePtr->length) {
if (messagePtr->callback) {
messagePtr->callback(p, messagePtr->callbackData, false, messagePtr->reserved);
......@@ -257,7 +257,7 @@ protected:
}
if (events & UV_READABLE) {
int length = recv(socket->getFd(), nodeData->recvBuffer, nodeData->recvLength, 0);
int length = (int) recv(socket->getFd(), nodeData->recvBuffer, nodeData->recvLength, 0);
if (length > 0) {
STATE::onData((Socket *) p, nodeData->recvBuffer, length);
} else if (length <= 0 || (length == SOCKET_ERROR && !netContext->wouldBlock())) {
......@@ -306,12 +306,12 @@ protected:
if (messageQueue.empty()) {
if (ssl) {
sent = SSL_write(ssl, message->data, message->length);
sent = SSL_write(ssl, message->data, (int) message->length);
if (sent == (ssize_t) message->length) {
wasTransferred = false;
return true;
} else if (sent < 0) {
switch (SSL_get_error(ssl, sent)) {
switch (SSL_get_error(ssl, (int) sent)) {
case SSL_ERROR_WANT_READ:
break;
case SSL_ERROR_WANT_WRITE:
......@@ -355,7 +355,7 @@ protected:
if (hasEmptyQueue()) {
if (estimatedLength <= uS::NodeData::preAllocMaxSize) {
int memoryLength = estimatedLength;
int memoryLength = (int) estimatedLength;
int memoryIndex = nodeData->getMemoryBlockIndex(memoryLength);
Queue::Message *messagePtr = (Queue::Message *) nodeData->getSmallMemoryBlock(memoryIndex);
......
......@@ -177,7 +177,7 @@ uS::Socket *WebSocket<isServer>::onData(uS::Socket *s, char *data, size_t length
webSocket->hasOutstandingPong = false;
if (!webSocket->isShuttingDown()) {
webSocket->cork(true);
WebSocketProtocol<isServer, WebSocket<isServer>>::consume(data, length, webSocket);
WebSocketProtocol<isServer, WebSocket<isServer>>::consume(data, (unsigned int) length, webSocket);
if (!webSocket->isClosed()) {
webSocket->cork(false);
}
......@@ -260,7 +260,7 @@ void WebSocket<isServer>::close(int code, const char *message, size_t length) {
startTimeout<WebSocket<isServer>::onEnd>();
char closePayload[MAX_CLOSE_PAYLOAD + 2];
int closePayloadLength = WebSocketProtocol<isServer, WebSocket<isServer>>::formatClosePayload(closePayload, code, message, length);
int closePayloadLength = (int) WebSocketProtocol<isServer, WebSocket<isServer>>::formatClosePayload(closePayload, code, message, length);
send(closePayload, closePayloadLength, OpCode::CLOSE, [](WebSocket<isServer> *p, void *data, bool cancelled, void *reserved) {
if (!cancelled) {
p->shutdown();
......
......@@ -127,7 +127,7 @@ private:
if (payLength + MESSAGE_HEADER <= length) {
if (isServer) {
unmaskImpreciseCopyMask(src + MESSAGE_HEADER - 4, src + MESSAGE_HEADER, src + MESSAGE_HEADER - 4, payLength);
unmaskImpreciseCopyMask(src + MESSAGE_HEADER - 4, src + MESSAGE_HEADER, src + MESSAGE_HEADER - 4, (unsigned int) payLength);
if (Impl::handleFragment(src + MESSAGE_HEADER - 4, payLength, 0, wState->state.opCode[wState->state.opStack], isFin(src), wState)) {
return true;
}
......@@ -148,7 +148,7 @@ private:
} else {
wState->state.spillLength = 0;
wState->state.wantsHead = false;
wState->remainingBytes = payLength - length + MESSAGE_HEADER;
wState->remainingBytes = (unsigned int) (payLength - length + MESSAGE_HEADER);
bool fin = isFin(src);
if (isServer) {
memcpy(wState->mask, src + MESSAGE_HEADER - 4, 4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment