From owner-svn-src-all@freebsd.org Sun Sep 29 11:33:01 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7239DFDC35; Sun, 29 Sep 2019 11:33:01 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 46h3LM5Hp4z4TNw; Sun, 29 Sep 2019 11:32:59 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 26EA443E0E9; Sun, 29 Sep 2019 21:32:54 +1000 (AEST) Date: Sun, 29 Sep 2019 21:32:53 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Warner Losh , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r352846 - head/lib/libc/sys In-Reply-To: <20190929092532.GO44691@kib.kiev.ua> Message-ID: <20190929204450.X1042@besplex.bde.org> References: <201909281715.x8SHFmZR034892@repo.freebsd.org> <20190929092532.GO44691@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=D+Q3ErZj c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=Fu6Zn4o2tIin4RjUpeQA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-Rspamd-Queue-Id: 46h3LM5Hp4z4TNw X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of brde@optusnet.com.au designates 211.29.132.246 as permitted sender) smtp.mailfrom=brde@optusnet.com.au X-Spamd-Result: default: False [-2.30 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:211.29.132.0/23]; FREEMAIL_FROM(0.00)[optusnet.com.au]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[optusnet.com.au]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(0.00)[ip: (-7.02), ipnet: 211.28.0.0/14(-3.28), asn: 4804(-2.42), country: AU(0.01)]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_NO_TLS_LAST(0.10)[]; RCVD_IN_DNSWL_LOW(-0.10)[246.132.29.211.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[optusnet.com.au]; ASN(0.00)[asn:4804, ipnet:211.28.0.0/14, country:AU]; MIME_TRACE(0.00)[0:+]; RWL_MAILSPIKE_POSSIBLE(0.00)[246.132.29.211.rep.mailspike.net : 127.0.0.17] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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, 29 Sep 2019 11:33:01 -0000 On Sun, 29 Sep 2019, Konstantin Belousov wrote: > On Sat, Sep 28, 2019 at 05:15:48PM +0000, Warner Losh wrote: >> Author: imp >> Date: Sat Sep 28 17:15:48 2019 >> New Revision: 352846 >> URL: https://svnweb.freebsd.org/changeset/base/352846 >> >> Log: >> Revert the mode_t -> int changes and add a warning in the BUGS section instead. >> >> While FreeBSD's implementation of these expect an int inside of libc, that's an >> implementation detail that we can hide from the user as it's the natural >> promotion of the current mode_t type and before it is used in the kernel, it's >> converted back to the narrower type that's the current definition of mode_t. As >> such, documenting int is at best confusing and at worst misleading. Instead add >> a note that these args are variadic and as such calling conventions may differ >> from non-variadic arguments. >> >> Modified: >> head/lib/libc/sys/mq_open.2 >> head/lib/libc/sys/open.2 >> >> Modified: head/lib/libc/sys/mq_open.2 >> ============================================================================== >> --- head/lib/libc/sys/mq_open.2 Sat Sep 28 14:20:28 2019 (r352845) >> +++ head/lib/libc/sys/mq_open.2 Sat Sep 28 17:15:48 2019 (r352846) >> @@ -37,7 +37,7 @@ >> .\" >> .\" $FreeBSD$ >> .\" >> -.Dd September 15, 2014 >> +.Dd September 28, 2019 >> .Dt MQ_OPEN 2 >> .Os >> .Sh NAME >> @@ -133,7 +133,7 @@ Create a message queue. >> It requires two additional arguments: >> .Fa mode , >> which is of type >> -.Vt int , >> +.Vt mode_t , >> and >> .Fa attr , >> which is a pointer to an >> @@ -317,6 +317,13 @@ This implementation places strict requirements on the >> it must begin with a slash >> .Pq Ql / >> and contain no other slash characters. >> +.Pp >> +The >> +.Fa mode >> +and >> +.Fa attr >> +arguments are variadic and may result in different calling conventions >> +than might otherwise be expected. >> .Sh COPYRIGHT >> Portions of this text are reprinted and reproduced in electronic form >> from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- >> >> Modified: head/lib/libc/sys/open.2 >> ============================================================================== >> --- head/lib/libc/sys/open.2 Sat Sep 28 14:20:28 2019 (r352845) >> +++ head/lib/libc/sys/open.2 Sat Sep 28 17:15:48 2019 (r352846) >> @@ -28,7 +28,7 @@ >> .\" @(#)open.2 8.2 (Berkeley) 11/16/93 >> .\" $FreeBSD$ >> .\" >> -.Dd September 17, 2019 >> +.Dd September 28, 2019 >> .Dt OPEN 2 >> .Os >> .Sh NAME >> @@ -61,7 +61,7 @@ In this case >> and >> .Fn openat >> require an additional argument >> -.Fa "int mode" , >> +.Fa "mode_t mode" , >> and the file is created with mode >> .Fa mode >> as described in >> @@ -615,3 +615,8 @@ permits searches. >> The present implementation of the >> .Fa openat >> checks the current permissions of directory instead. >> +.Pp >> +The >> +.Fa mode >> +argument is variadic and may result in different calling conventions >> +than might otherwise be expected. > This note is also very confusing. > > Assume that somebody knows calling conventions and then see this note. > Now she would be equally misdirected because it is completely not clear > what different conventions are mentioned there, esp. because there are no. > > Also, as I noted before, this note in whatever form does not belongs to > BUSS section. I was going to say "Indeed. The man page already gives the type mode_t for the mode, so the fix should be to remind the reader that since open() is variadic, the caller MUST supply an arg whose type is the default promotion of mode_t [and this is most easily done by starting with or casting to an arg whose type is precisely mode_t]. POSIX gets this wronger. It says "the file mode shall be set to the value of the argument following the oflag argument taken as type mode_t". It never defines the actual type of this arg. Since open() is variadic, the actual type is the default promotion of whatever the caller passes. Nothing forbids the caller passing a long long or even a long double, or even any type with any encoding. Literally, this requires the implementation to "take" the arg as a mode_t using an unspecified conversion method after using magic beyond va_arg() to determine the type and value of the arg. POSIX give an example where the arg type is precisely mode_t, but this is just an example of one arg type that works. All this was in the 2001 version of POSIX and remains unfixed in the 2018 version. So the man page was wrong after all. It was not bug for bug compatible with POSIX, since it says that the additional argument is "mode_t mode" but POSIX allows any type that can be "taken" as a mode_t. This shouldn't change the fix. The BUGS section is not the place to document bugs in POSIX. Bruce