mirror of
https://github.com/openbsd/src.git
synced 2026-06-19 15:53:31 +02:00
Make pthread_mutex_destroy() not error out for mutexes that were initalized
with PTHREAD_MUTEX_INITIALIZER but not used. Unify handling of mutexp == NULL in both version of pthread_mutex_destroy() and ensure that *mutexp == NULL is not considered an error. Problem found by tb@ with rpki-client. OK kettenis@ tb@
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rthread_mutex.c,v 1.7 2025/08/03 06:42:31 dlg Exp $ */
|
||||
/* $OpenBSD: rthread_mutex.c,v 1.8 2026/03/27 12:26:58 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2017 Martin Pieuchot <mpi@openbsd.org>
|
||||
* Copyright (c) 2012 Philip Guenther <guenther@openbsd.org>
|
||||
@@ -73,7 +73,7 @@ pthread_mutex_destroy(pthread_mutex_t *mutexp)
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
if (mutexp == NULL || *mutexp == NULL)
|
||||
if (mutexp == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
mutex = *mutexp;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rthread_sync.c,v 1.6 2024/01/10 04:28:43 cheloha Exp $ */
|
||||
/* $OpenBSD: rthread_sync.c,v 1.7 2026/03/27 12:26:58 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
|
||||
* Copyright (c) 2012 Philip Guenther <guenther@openbsd.org>
|
||||
@@ -64,7 +64,9 @@ pthread_mutex_destroy(pthread_mutex_t *mutexp)
|
||||
{
|
||||
struct pthread_mutex *mutex;
|
||||
|
||||
assert(mutexp);
|
||||
if (mutexp == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
mutex = (struct pthread_mutex *)*mutexp;
|
||||
if (mutex) {
|
||||
if (mutex->count || mutex->owner != NULL ||
|
||||
|
||||
Reference in New Issue
Block a user