Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpthread Fix error handling
details: https://anonhg.NetBSD.org/src/rev/833c001b6824
branches: trunk
changeset: 777934:833c001b6824
user: joerg <joerg%NetBSD.org@localhost>
date: Sat Mar 10 18:01:10 2012 +0000
description:
Fix error handling
diffstat:
lib/libpthread/sem.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diffs (73 lines):
diff -r fe7b2b848f9c -r 833c001b6824 lib/libpthread/sem.c
--- a/lib/libpthread/sem.c Sat Mar 10 18:01:09 2012 +0000
+++ b/lib/libpthread/sem.c Sat Mar 10 18:01:10 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.23 2012/03/08 21:59:28 joerg Exp $ */
+/* $NetBSD: sem.c,v 1.24 2012/03/10 18:01:10 joerg Exp $ */
/*-
* Copyright (c) 2003, 2006, 2007 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: sem.c,v 1.23 2012/03/08 21:59:28 joerg Exp $");
+__RCSID("$NetBSD: sem.c,v 1.24 2012/03/10 18:01:10 joerg Exp $");
#include <sys/types.h>
#include <sys/ksem.h>
@@ -135,6 +135,7 @@
int
sem_destroy(sem_t *sem)
{
+ int error, save_errno;
#ifdef ERRORCHECK
if (sem == NULL || *sem == NULL || (*sem)->ksem_magic != KSEM_MAGIC) {
@@ -143,12 +144,12 @@
}
#endif
- if (_ksem_destroy((*sem)->ksem_semid) == -1)
- return (-1);
+ error = _ksem_destroy((*sem)->ksem_semid);
+ save_errno = errno;
+ sem_free(*sem);
+ errno = save_errno;
- sem_free(*sem);
-
- return (0);
+ return error;
}
sem_t *
@@ -218,6 +219,7 @@
int
sem_close(sem_t *sem)
{
+ int error, save_errno;
#ifdef ERRORCHECK
if (sem == NULL || *sem == NULL || (*sem)->ksem_magic != KSEM_MAGIC) {
@@ -227,16 +229,14 @@
#endif
pthread_mutex_lock(&named_sems_mtx);
- if (_ksem_close((*sem)->ksem_semid) == -1) {
- pthread_mutex_unlock(&named_sems_mtx);
- return (-1);
- }
-
+ error = _ksem_close((*sem)->ksem_semid);
LIST_REMOVE((*sem), ksem_list);
+ save_errno = errno;
pthread_mutex_unlock(&named_sems_mtx);
sem_free(*sem);
free(sem);
- return (0);
+ errno = save_errno;
+ return error;
}
int
Home |
Main Index |
Thread Index |
Old Index