Fix warnings

This commit is contained in:
2025-12-18 21:03:05 +02:00
parent 0782ea889c
commit 1b2d6372b2

View File

@@ -318,11 +318,11 @@ Window* SDLPlatform::CreateWindow(const CreateWindowSettings& settings)
return New<SDLWindow>(settings); return New<SDLWindow>(settings);
} }
bool ReadStream(SDL_IOStream*& stream, char* buffer, int32 bufferLength, int32& bufferPosition, LogType logType, CreateProcessSettings& settings) bool ReadStream(SDL_IOStream*& stream, char* buffer, int64 bufferLength, int64& bufferPosition, LogType logType, CreateProcessSettings& settings)
{ {
bool flushBuffer = false; bool flushBuffer = false;
bool success = true; bool success = true;
int32 read = SDL_ReadIO(stream, buffer + bufferPosition, bufferLength - bufferPosition - 1); auto read = SDL_ReadIO(stream, buffer + bufferPosition, bufferLength - bufferPosition - 1);
if (read == 0) if (read == 0)
{ {
SDL_IOStatus status = SDL_GetIOStatus(stream); SDL_IOStatus status = SDL_GetIOStatus(stream);
@@ -336,8 +336,8 @@ bool ReadStream(SDL_IOStream*& stream, char* buffer, int32 bufferLength, int32&
} }
else else
{ {
int32 startPosition = bufferPosition; int64 startPosition = bufferPosition;
bufferPosition += read; bufferPosition += (int64)read;
if (bufferPosition == bufferLength - 1) if (bufferPosition == bufferLength - 1)
{ {
flushBuffer = true; flushBuffer = true;
@@ -345,7 +345,7 @@ bool ReadStream(SDL_IOStream*& stream, char* buffer, int32 bufferLength, int32&
} }
else else
{ {
for (int i = startPosition; i < bufferPosition; ++i) for (int64 i = startPosition; i < bufferPosition; ++i)
{ {
if (buffer[i] == '\n') if (buffer[i] == '\n')
{ {
@@ -358,13 +358,13 @@ bool ReadStream(SDL_IOStream*& stream, char* buffer, int32 bufferLength, int32&
if (flushBuffer) if (flushBuffer)
{ {
int32 start = 0; int64 start = 0;
for (int i = 0; i < bufferPosition; ++i) for (int64 i = 0; i < bufferPosition; ++i)
{ {
if (buffer[i] != '\n') if (buffer[i] != '\n')
continue; continue;
String str(&buffer[start], i - start + 1); String str(&buffer[start], (int32)(i - start + 1));
#if LOG_ENABLE #if LOG_ENABLE
if (settings.LogOutput) if (settings.LogOutput)
Log::Logger::Write(logType, StringView(str.Get(), str.Length() - 1)); Log::Logger::Write(logType, StringView(str.Get(), str.Length() - 1));
@@ -373,7 +373,7 @@ bool ReadStream(SDL_IOStream*& stream, char* buffer, int32 bufferLength, int32&
settings.Output.Add(str.Get(), str.Length()); settings.Output.Add(str.Get(), str.Length());
start = i + 1; start = i + 1;
} }
int32 length = bufferPosition - start; int64 length = bufferPosition - start;
if (length > 0) if (length > 0)
{ {
// TODO: Use memmove here? Overlapped memory regions with memcpy is undefined behaviour // TODO: Use memmove here? Overlapped memory regions with memcpy is undefined behaviour
@@ -444,12 +444,12 @@ int32 SDLPlatform::CreateProcess(CreateProcessSettings& settings)
SDL_DestroyEnvironment(env); SDL_DestroyEnvironment(env);
if (process == nullptr) if (process == nullptr)
{ {
LOG(Error, "Failed to run process {}: {}", String(settings.FileName).Get(), String(SDL_GetError())); LOG(Error, "Failed to run process {}: {}", settings.FileName.Get(), String(SDL_GetError()));
return -1; return -1;
} }
props = SDL_GetProcessProperties(process); props = SDL_GetProcessProperties(process);
int32 pid = SDL_GetNumberProperty(props, SDL_PROP_PROCESS_PID_NUMBER, 0); int64 pid = SDL_GetNumberProperty(props, SDL_PROP_PROCESS_PID_NUMBER, 0);
SDL_IOStream* stdoutStream = nullptr; SDL_IOStream* stdoutStream = nullptr;
SDL_IOStream* stderrStream = nullptr; SDL_IOStream* stderrStream = nullptr;
if (captureStdOut) if (captureStdOut)
@@ -460,9 +460,9 @@ int32 SDLPlatform::CreateProcess(CreateProcessSettings& settings)
// Handle process output in realtime // Handle process output in realtime
char stdoutBuffer[2049]; char stdoutBuffer[2049];
int32 stdoutPosition = 0; int64 stdoutPosition = 0;
char stderrBuffer[2049]; char stderrBuffer[2049];
int32 stderrPosition = 0; int64 stderrPosition = 0;
while (stdoutStream != nullptr && stderrStream != nullptr) while (stdoutStream != nullptr && stderrStream != nullptr)
{ {
if (stdoutStream != nullptr && !ReadStream(stdoutStream, stdoutBuffer, sizeof(stdoutBuffer), stdoutPosition, LogType::Info, settings)) if (stdoutStream != nullptr && !ReadStream(stdoutStream, stdoutBuffer, sizeof(stdoutBuffer), stdoutPosition, LogType::Info, settings))