Prevents a warning of `r` being shadowed, and makes the code clearer.

Signed-off-by: Antonin Décimo <anto...@tarides.com>
---
 mingw-w64-libraries/winpthreads/src/rwlock.c | 6 +++++-
 mingw-w64-libraries/winpthreads/src/rwlock.h | 3 ---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-libraries/winpthreads/src/rwlock.c 
b/mingw-w64-libraries/winpthreads/src/rwlock.c
index 933d43885..f2496f3db 100644
--- a/mingw-w64-libraries/winpthreads/src/rwlock.c
+++ b/mingw-w64-libraries/winpthreads/src/rwlock.c
@@ -47,7 +47,11 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int 
rwl_unref(volatile pthread_rwlock_t
 static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_ref(pthread_rwlock_t *rwl, 
int f )
 {
     int r = 0;
-    INIT_RWLOCK(rwl);
+    if (STATIC_RWL_INITIALIZER(*rwl)) {
+        r = rwlock_static_init(rwl);
+        if (r != 0 && r != EBUSY)
+            return r;
+    }
     pthread_spin_lock(&rwl_global);
 
     if (!rwl || !*rwl || ((rwlock_t *)*rwl)->valid != LIFE_RWLOCK) r = EINVAL;
diff --git a/mingw-w64-libraries/winpthreads/src/rwlock.h 
b/mingw-w64-libraries/winpthreads/src/rwlock.h
index f08b0d37b..2d640faa9 100644
--- a/mingw-w64-libraries/winpthreads/src/rwlock.h
+++ b/mingw-w64-libraries/winpthreads/src/rwlock.h
@@ -26,9 +26,6 @@
 #define LIFE_RWLOCK 0xBAB1F0ED
 #define DEAD_RWLOCK 0xDEADB0EF
 
-#define INIT_RWLOCK(rwl)  { int r; \
-    if (STATIC_RWL_INITIALIZER(*rwl)) { if ((r = rwlock_static_init(rwl))) { 
if (r != EBUSY) return r; }}}
-
 #define STATIC_RWL_INITIALIZER(x)              ((pthread_rwlock_t)(x) == 
((pthread_rwlock_t)PTHREAD_RWLOCK_INITIALIZER))
 
 typedef struct rwlock_t rwlock_t;
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to