From owner-svn-src-all@FreeBSD.ORG Mon Jan 18 10:29:05 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23C141065670; Mon, 18 Jan 2010 10:29:05 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 138DD8FC16; Mon, 18 Jan 2010 10:29:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0IAT4MD031130; Mon, 18 Jan 2010 10:29:04 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0IAT4Dk031128; Mon, 18 Jan 2010 10:29:04 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201001181029.o0IAT4Dk031128@svn.freebsd.org> From: David Xu Date: Mon, 18 Jan 2010 10:29:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202557 - head/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2010 10:29:05 -0000 Author: davidxu Date: Mon Jan 18 10:29:04 2010 New Revision: 202557 URL: http://svn.freebsd.org/changeset/base/202557 Log: preserve errno when processing error cases. Modified: head/lib/libc/gen/sem_new.c Modified: head/lib/libc/gen/sem_new.c ============================================================================== --- head/lib/libc/gen/sem_new.c Mon Jan 18 10:17:51 2010 (r202556) +++ head/lib/libc/gen/sem_new.c Mon Jan 18 10:29:04 2010 (r202557) @@ -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); }