From 6875e1c262ae968a4fb52b367cf6912d9c76d4c9 Mon Sep 17 00:00:00 2001
From: pionere <[EMAIL REDACTED]>
Date: Tue, 29 Nov 2022 11:18:30 +0100
Subject: [PATCH] thread: fix inconsistent return values - SDL_CreateMutex
returns NULL when the creation fails (ngage) - SDL_SemValue returns 0 when
the semaphore is NULL (n3ds)
---
src/thread/n3ds/SDL_syssem.c | 3 ++-
src/thread/ngage/SDL_sysmutex.cpp | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c
index 4bee6563a630..82fc2d3ec3b7 100644
--- a/src/thread/n3ds/SDL_syssem.c
+++ b/src/thread/n3ds/SDL_syssem.c
@@ -113,7 +113,8 @@ Uint32
SDL_SemValue(SDL_sem *sem)
{
if (sem == NULL) {
- return SDL_InvalidParamError("sem");
+ SDL_InvalidParamError("sem");
+ return 0;
}
return sem->semaphore.current_count;
}
diff --git a/src/thread/ngage/SDL_sysmutex.cpp b/src/thread/ngage/SDL_sysmutex.cpp
index 3f0dd0d180a9..ffac6c38b314 100644
--- a/src/thread/ngage/SDL_sysmutex.cpp
+++ b/src/thread/ngage/SDL_sysmutex.cpp
@@ -47,6 +47,7 @@ SDL_CreateMutex(void)
TInt status = CreateUnique(NewMutex, &rmutex, NULL);
if (status != KErrNone) {
SDL_SetError("Couldn't create mutex.");
+ return NULL;
}
SDL_mutex* mutex = new /*(ELeave)*/ SDL_mutex;
mutex->handle = rmutex.Handle();