From owner-svn-src-head@freebsd.org Thu Dec 7 04:31:22 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 12F73E9C355; Thu, 7 Dec 2017 04:31:22 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id CDD19753B6; Thu, 7 Dec 2017 04:31:21 +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 mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 909ECD4343D; Thu, 7 Dec 2017 15:31:13 +1100 (AEDT) Date: Thu, 7 Dec 2017 15:31:11 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Mark Johnston cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r326626 - head/lib/libproc In-Reply-To: <201712061752.vB6Hq1LZ031860@repo.freebsd.org> Message-ID: <20171207142408.F1895@besplex.bde.org> References: <201712061752.vB6Hq1LZ031860@repo.freebsd.org> 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=KeqiiUQD c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=WTDbq_u4yy9RV7ibXkYA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Thu, 07 Dec 2017 04:31:22 -0000 On Wed, 6 Dec 2017, Mark Johnston wrote: > Log: > Use a global extern declaration to appease gcc. Why not do this to fix the bug which is reported by gcc as requested by using -Wnested-externs (given by WARNS?=6 in ../Makefile.inc). clang doesn't suuport this option except in a broken way by ignoring it. -Wnested-includes is turned off for CXX in sys.mk, but that doesn't apply here. > Modified: head/lib/libproc/proc_create.c > ============================================================================== > --- head/lib/libproc/proc_create.c Wed Dec 6 17:50:10 2017 (r326625) > +++ head/lib/libproc/proc_create.c Wed Dec 6 17:52:01 2017 (r326626) > @@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$"); > > #include "_libproc.h" > > +extern char * const *environ; > + > static int getelfclass(int); > static int proc_init(pid_t, int, int, struct proc_handle **); > > @@ -179,7 +181,6 @@ int > proc_create(const char *file, char * const *argv, char * const *envp, > proc_child_func *pcf, void *child_arg, struct proc_handle **pphdl) > { > - extern char * const *environ; > struct proc_handle *phdl; > int error, status; > pid_t pid; This is still broken. 'environ' is hard to use since it is not declared in any standard header, but it has a whole man page environ(7) whose synoposis declares it as char **. The type mismatch is not detected because no header files that declares 'environ' is included (because none exists). 'environ' is also documented in exec(3) and posix_spawn(3). 'environ' is correctly declared in all 9 other source files and 3 man pages in /usr/src/lib/ that declare it. Declaring it as extern in file scope is worse in some ways that declaring it in block scope, since it breaks this warning so that the bug of misdeclaring it is harder to notice. WARNS=6 also enables -Wredundant-decls to detect this bug when it is only a style bug. Normally variables are declared in headers, so redeclaring them in .c files is a type mismatch if the declarations are compatible (not necessarily the same) and a style bug if they are compatible. gcc up to least 4.2.1] has some bugs involving it not understanding redundancy. clang silently ignores this option too. Bruce