From b678a9802435152324e0603055e4bb190d0ae526 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 17 Dec 2022 06:58:02 -0800
Subject: [PATCH] Fixed compiler warning
./src/thread/pthread/SDL_syssem.c:140:12: warning: variable ‘retval’ is used uninitialized whenever ‘while’ loop exits because its condition is false [-Wsometimes-uninitialized]
while (sem_trywait(&sem->sem) != 0) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/thread/pthread/SDL_syssem.c:149:12: note: uninitialized use occurs here
return retval;
^~~~~~
./src/thread/pthread/SDL_syssem.c:140:12: note: remove the condition if it is always true
while (sem_trywait(&sem->sem) != 0) {
This was a legitimate bug, thank you clang!
Fixes https://github.com/libsdl-org/SDL/issues/6830
---
src/thread/pthread/SDL_syssem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c
index 65179461aae3..0a244db4e5bb 100644
--- a/src/thread/pthread/SDL_syssem.c
+++ b/src/thread/pthread/SDL_syssem.c
@@ -65,7 +65,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{
- int retval;
+ int retval = 0;
#ifdef HAVE_SEM_TIMEDWAIT
#ifndef HAVE_CLOCK_GETTIME
struct timeval now;