From owner-svn-src-all@FreeBSD.ORG Sun Feb 1 22:50:34 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CBE64A16; Sun, 1 Feb 2015 22:50:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B6AC6F2A; Sun, 1 Feb 2015 22:50:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t11MoY7Z054982; Sun, 1 Feb 2015 22:50:34 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t11MoYMh054980; Sun, 1 Feb 2015 22:50:34 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201502012250.t11MoYMh054980@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 1 Feb 2015 22:50:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278038 - in head: contrib/netbsd-tests/lib/libc/gen lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Sun, 01 Feb 2015 22:50:34 -0000 Author: jilles Date: Sun Feb 1 22:50:33 2015 New Revision: 278038 URL: https://svnweb.freebsd.org/changeset/base/278038 Log: ttyname_r(): Return actual error, not always [ENOTTY]. Adjust the test that used to fail because of this bug. PR: 191936 MFC after: 1 week Modified: head/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c head/lib/libc/gen/ttyname.c Modified: head/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c Sun Feb 1 21:50:28 2015 (r278037) +++ head/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c Sun Feb 1 22:50:33 2015 (r278038) @@ -107,9 +107,6 @@ ATF_TC_BODY(ttyname_r_err, tc) ATF_REQUIRE(rv == ERANGE); } -#ifdef __FreeBSD__ - atf_tc_expect_fail("FreeBSD returns ENOTTY instead of EBADF; see bin/191936"); -#endif rv = ttyname_r(-1, buf, ttymax); ATF_REQUIRE(rv == EBADF); Modified: head/lib/libc/gen/ttyname.c ============================================================================== --- head/lib/libc/gen/ttyname.c Sun Feb 1 21:50:28 2015 (r278037) +++ head/lib/libc/gen/ttyname.c Sun Feb 1 22:50:33 2015 (r278038) @@ -65,7 +65,7 @@ ttyname_r(int fd, char *buf, size_t len) /* Must be a terminal. */ if (!isatty(fd)) - return (ENOTTY); + return (errno); /* Must have enough room */ if (len <= sizeof(_PATH_DEV)) return (ERANGE); @@ -73,7 +73,7 @@ ttyname_r(int fd, char *buf, size_t len) strcpy(buf, _PATH_DEV); used = strlen(buf); if (fdevname_r(fd, buf + used, len - used) == NULL) - return (ENOTTY); + return (errno == EINVAL ? ERANGE : errno); return (0); }