From owner-svn-src-head@FreeBSD.ORG Mon Mar 23 23:43:08 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2988A1065673; Mon, 23 Mar 2009 23:43:08 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 17ECE8FC12; Mon, 23 Mar 2009 23:43:08 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2NNh7Wx025077; Mon, 23 Mar 2009 23:43:08 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2NNh7LE025076; Mon, 23 Mar 2009 23:43:07 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200903232343.n2NNh7LE025076@svn.freebsd.org> From: Xin LI Date: Mon, 23 Mar 2009 23:43:07 +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: r190344 - head/lib/libc/db/btree X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2009 23:43:09 -0000 Author: delphij Date: Mon Mar 23 23:43:07 2009 New Revision: 190344 URL: http://svn.freebsd.org/changeset/base/190344 Log: Save errno before calling _close(), which may clear it. Obtained from: OpenBSD Modified: head/lib/libc/db/btree/bt_open.c Modified: head/lib/libc/db/btree/bt_open.c ============================================================================== --- head/lib/libc/db/btree/bt_open.c Mon Mar 23 23:32:20 2009 (r190343) +++ head/lib/libc/db/btree/bt_open.c Mon Mar 23 23:43:07 2009 (r190344) @@ -96,7 +96,7 @@ __bt_open(const char *fname, int flags, DB *dbp; pgno_t ncache; ssize_t nr; - int machine_lorder; + int machine_lorder, saved_errno; t = NULL; @@ -327,13 +327,15 @@ einval: errno = EINVAL; eftype: errno = EFTYPE; goto err; -err: if (t) { +err: saved_errno = errno; + if (t) { if (t->bt_dbp) free(t->bt_dbp); if (t->bt_fd != -1) (void)_close(t->bt_fd); free(t); } + errno = saved_errno; return (NULL); }