From f75d7d13a075d8f3a0bcf9614f61937911e937f7 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Sat, 11 May 2024 19:43:13 -0500 Subject: [PATCH] [Net/Web] Fixed strict reduce types to 32 bit sizes, changed to memsize --- Common/Net/HTTPServer.cpp | 2 +- Common/Net/NetBuffer.cpp | 6 +++--- Common/Net/Sinks.cpp | 8 ++++---- Core/WebServer.cpp | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Common/Net/HTTPServer.cpp b/Common/Net/HTTPServer.cpp index a4e19d805b..83d90a94bd 100644 --- a/Common/Net/HTTPServer.cpp +++ b/Common/Net/HTTPServer.cpp @@ -353,7 +353,7 @@ void Server::HandleRequestDefault(const ServerRequest &request) { void Server::Handle404(const ServerRequest &request) { INFO_LOG(IO, "No handler for '%s', falling back to 404.", request.resource()); const char *payload = "404 not found\r\n"; - request.WriteHttpResponseHeader("1.0", 404, (int)strlen(payload)); + request.WriteHttpResponseHeader("1.0", 404, strlen(payload)); request.Out()->Push(payload); } diff --git a/Common/Net/NetBuffer.cpp b/Common/Net/NetBuffer.cpp index 09a4853963..1682582440 100644 --- a/Common/Net/NetBuffer.cpp +++ b/Common/Net/NetBuffer.cpp @@ -48,7 +48,7 @@ bool Buffer::FlushSocket(uintptr_t sock, double timeout, bool *cancelled) { return false; } } - int sent = send(sock, &data_[pos], (int)(end - pos), MSG_NOSIGNAL); + int sent = send(sock, &data_[pos], end - pos, MSG_NOSIGNAL); // TODO: Do we need some retry logic here, instead of just giving up? if (sent < 0) { ERROR_LOG(IO, "FlushSocket failed to send: %d", errno); @@ -85,7 +85,7 @@ bool Buffer::ReadAllWithProgress(int fd, int knownSize, RequestProgress *progres ready = fd_util::WaitUntilReady(fd, CANCEL_INTERVAL, false); } - int retval = recv(fd, &buf[0], (int)buf.size(), MSG_NOSIGNAL); + int retval = recv(fd, &buf[0], buf.size(), MSG_NOSIGNAL); if (retval == 0) { return true; } else if (retval < 0) { @@ -116,7 +116,7 @@ int Buffer::Read(int fd, size_t sz) { char buf[1024]; int retval; size_t received = 0; - while ((retval = recv(fd, buf, (int)std::min(sz, sizeof(buf)), MSG_NOSIGNAL)) > 0) { + while ((retval = recv(fd, buf, std::min(sz, sizeof(buf)), MSG_NOSIGNAL)) > 0) { if (retval < 0) { return retval; } diff --git a/Common/Net/Sinks.cpp b/Common/Net/Sinks.cpp index 62eb407dac..0d18cbaf09 100644 --- a/Common/Net/Sinks.cpp +++ b/Common/Net/Sinks.cpp @@ -176,7 +176,7 @@ void InputSink::Fill() { // Whatever isn't valid and follows write_ is what's available. size_t avail = BUFFER_SIZE - std::max(write_, valid_); - int bytes = recv(fd_, buf_ + write_, (int)avail, MSG_NOSIGNAL); + int bytes = recv(fd_, buf_ + write_, avail, MSG_NOSIGNAL); AccountFill(bytes); } } @@ -266,7 +266,7 @@ size_t OutputSink::PushAtMost(const char *buf, size_t bytes) { if (valid_ == 0 && bytes > PRESSURE) { // Special case for pushing larger buffers: let's try to send directly. - int sentBytes = send(fd_, buf, (int)bytes, MSG_NOSIGNAL); + int sentBytes = send(fd_, buf, bytes, MSG_NOSIGNAL); // If it was 0 or EWOULDBLOCK, that's fine, we'll enqueue as we can. if (sentBytes > 0) { return sentBytes; @@ -348,7 +348,7 @@ bool OutputSink::Flush(bool allowBlock) { while (valid_ > 0) { size_t avail = std::min(BUFFER_SIZE - read_, valid_); - int bytes = send(fd_, buf_ + read_, (int)avail, MSG_NOSIGNAL); + int bytes = send(fd_, buf_ + read_, avail, MSG_NOSIGNAL); #if !PPSSPP_PLATFORM(WINDOWS) if (bytes == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) bytes = 0; @@ -380,7 +380,7 @@ void OutputSink::Drain() { // Let's just do contiguous valid. size_t avail = std::min(BUFFER_SIZE - read_, valid_); - int bytes = send(fd_, buf_ + read_, (int)avail, MSG_NOSIGNAL); + int bytes = send(fd_, buf_ + read_, avail, MSG_NOSIGNAL); #if !PPSSPP_PLATFORM(WINDOWS) if (bytes == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) bytes = 0; diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index e7a80ae486..21987575ad 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -332,7 +332,7 @@ static bool ServeDebuggerFile(const http::ServerRequest &request) { mimeType = "text/css"; } - request.WriteHttpResponseHeader("1.0", 200, (int)size, mimeType); + request.WriteHttpResponseHeader("1.0", 200, size, mimeType); request.Out()->Push((char *)data, size); delete[] data; @@ -341,7 +341,7 @@ static bool ServeDebuggerFile(const http::ServerRequest &request) { static void RedirectToDebugger(const http::ServerRequest &request) { static const std::string payload = "Redirecting to debugger UI...\r\n"; - request.WriteHttpResponseHeader("1.0", 301, (int)payload.size(), "text/plain", "Location: /debugger/index.html\r\n"); + request.WriteHttpResponseHeader("1.0", 301, payload.size(), "text/plain", "Location: /debugger/index.html\r\n"); request.Out()->Push(payload); } @@ -375,7 +375,7 @@ static void HandleFallback(const http::ServerRequest &request) { } static const std::string payload = "404 not found\r\n"; - request.WriteHttpResponseHeader("1.0", 404, (int)payload.size(), "text/plain"); + request.WriteHttpResponseHeader("1.0", 404, payload.size(), "text/plain"); request.Out()->Push(payload); }