mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
preserve errno when processing error cases.
This commit is contained in:
parent
dcdafd0e92
commit
4c1c132bf4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=202557
@ -142,7 +142,7 @@ _sem_open(const char *name, int flags, ...)
|
||||
va_list ap;
|
||||
struct sem_nameinfo *ni = NULL;
|
||||
sem_t *sem = NULL;
|
||||
int fd = -1, mode, len;
|
||||
int fd = -1, mode, len, errsave;
|
||||
int value = 0;
|
||||
|
||||
if (name[0] != '/') {
|
||||
@ -233,12 +233,14 @@ _sem_open(const char *name, int flags, ...)
|
||||
return (sem);
|
||||
|
||||
error:
|
||||
errsave = errno;
|
||||
_pthread_mutex_unlock(&sem_llock);
|
||||
if (fd != -1)
|
||||
_close(fd);
|
||||
if (sem != NULL)
|
||||
munmap(sem, sizeof(sem_t));
|
||||
free(ni);
|
||||
errno = errsave;
|
||||
return (SEM_FAILED);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user