From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11478 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 2/3] confstr: don't give empty strings for unset values Date: Wed, 14 Jun 2017 20:00:05 -0400 Message-ID: <20170615000005.GJ1627@brightrain.aerifal.cx> References: <5898F7D9.7090403@adelielinux.org> <20170609052618.5875-1-awilfox@adelielinux.org> <20170609052618.5875-3-awilfox@adelielinux.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1497484819 22785 195.159.176.226 (15 Jun 2017 00:00:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Jun 2017 00:00:19 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11491-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jun 15 02:00:16 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dLICu-0005k8-17 for gllmg-musl@m.gmane.org; Thu, 15 Jun 2017 02:00:16 +0200 Original-Received: (qmail 20154 invoked by uid 550); 15 Jun 2017 00:00:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 20125 invoked from network); 15 Jun 2017 00:00:17 -0000 Content-Disposition: inline In-Reply-To: <20170609052618.5875-3-awilfox@adelielinux.org> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11478 Archived-At: On Fri, Jun 09, 2017 at 12:26:17AM -0500, A. Wilcox wrote: > From: "A. Wilcox" > > If confstr(3) returns an empty string, that means the implementation > supports the configuration and simply needs no setting. Some values > should actually be unset on musl. This change ensures that > configurations not supported by musl do not have values. > --- > src/conf/confstr.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/src/conf/confstr.c b/src/conf/confstr.c > index 02cb1aa..c899abd 100644 > --- a/src/conf/confstr.c > +++ b/src/conf/confstr.c > @@ -11,6 +11,19 @@ size_t confstr(int name, char *buf, size_t len) > errno = EINVAL; > return 0; > } > + > + if (name == _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS || > + // Since sysconf _SC_V7_ILP32_OFF32 = -1 > + name == _CS_POSIX_V7_ILP32_OFF32_CFLAGS || > + name == _CS_POSIX_V7_ILP32_OFF32_LDFLAGS || > + name == _CS_POSIX_V7_ILP32_OFF32_LIBS || > + // Since sysconf _SC_V7_LPBIG_OFFBIG = -1 > + name == _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS || > + name == _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS || > + name == _CS_POSIX_V7_LPBIG_OFFBIG_LIBS) { > + return 0; > + } I'm not sure musl is actually correct in reporting these right now. POSIX describes LPBIG_OFFBIG as long, pointer, and off_t being "at least 64 bits", which is the case on 64-bit archs. Of course ILP32_OFF32 is always false. But I don't think POSIX imposes any requirement that we return an error here anyway. See unistd.h: _CS_POSIX_V7_ILP32_OFF32_CFLAGS If sysconf(_SC_V7_ILP32_OFF32) returns -1, the meaning of this value is unspecified. ^^^^^^^^^^^ Also I'm not sure what makes sense to return for _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS. On most archs, the only compilation environment does satisfy the conditions, but it doesn't have a name that can be passed to getconf -v. On some (x32, maybe n32?) archs, strictly speaking we're nonconforming by not having such an environment (I think at least suseconds_t is wrong, maybe blksize_t too). The requirements for interaction with POSIX.2 (xcu c99 and getconf commands) make this whole area a mess to implement since we don't control that part of the implementation. BTW your other two patches look fine, committing them. Rich