Skip to content

Commit

Permalink
Merge pull request #19135 from GermanAizek/fix-memsize-types
Browse files Browse the repository at this point in the history
[Net/Web/Util] Fixed strict reduce types to 32 bit sizes, changed to memsize
  • Loading branch information
hrydgard committed May 12, 2024
2 parents 5e6f5ea + 27d0ac6 commit 2fdd893
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Common/Net/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<html><body>404 not found</body></html>\r\n";
request.WriteHttpResponseHeader("1.0", 404, (int)strlen(payload));
request.WriteHttpResponseHeader("1.0", 404, strlen(payload));
request.Out()->Push(payload);
}

Expand Down
6 changes: 3 additions & 3 deletions Common/Net/NetBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions Common/Net/Sinks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Core/Util/MemStick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ MoveResult *MoveDirectoryContentsSafe(Path moveSrc, Path moveDest, MoveProgressR
bool ok = true;
for (size_t i = 0; i < fileSuffixesToMove.size(); i++) {
const auto &fileSuffix = fileSuffixesToMove[i];
progressReporter.SetProgress(ms->T("Checking..."), (int)i, (int)fileSuffixesToMove.size());
progressReporter.SetProgress(ms->T("Checking..."), i, fileSuffixesToMove.size());

Path to = moveDest / fileSuffix.suffix;

Expand Down
6 changes: 3 additions & 3 deletions Core/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 2fdd893

Please sign in to comment.