svn commit: r243321 - head/usr.sbin/edquota

Bruce Evans brde at optusnet.com.au
Tue Nov 20 07:04:03 UTC 2012


On Tue, 20 Nov 2012, Eitan Adler wrote:

> Log:
>  Remove unneeded includes.
>
>  Tested with "make universe"; there are no conditional features.

"make universe" can't find such features.  Except inversely -- when it
doesn't find them, it usually means that there is a bug in the headers.

> Modified: head/usr.sbin/edquota/edquota.c
> ==============================================================================
> --- head/usr.sbin/edquota/edquota.c	Tue Nov 20 01:57:21 2012	(r243320)
> +++ head/usr.sbin/edquota/edquota.c	Tue Nov 20 02:12:01 2012	(r243321)
> @@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$");
>  * Disk quota editor.
>  */
>
> -#include <sys/param.h>
> -#include <sys/stat.h>
> #include <sys/file.h>
> #include <sys/mount.h>
> #include <sys/wait.h>
>

This removes used includes.

<sys/param.h> is a documented prerequisite of <sys/mount.h>.  sys/mount.h
has some pollution but not that until recently.  <sys/mount.h> has included
<sys/ucred.h> for a long time, and someone recently added the following
disgusting pollution to <sys/ucred.h>:
- <sys/ucred.h> includes <bsm/audit.h>
- <bsm/audit.h> includes <sys/param.h> and all of its standard pollution
   According to cc -E -MM, this is:

% f.o: f.c /usr/include/bsm/audit.h /usr/include/sys/param.h \
                                     ^^^^^^^^^^^^^^^^^^^^^^^^

Polluting headers are underlined.

%   /usr/include/sys/_null.h /usr/include/sys/types.h \
                              ^^^^^^^^^^^^^^^^^^^^^^^^

<bsm/audit.h> is of low quality.  It also includes <sys/types.h> after
<sys/param.h>.  This is a style bug.  <sys/types.h> is standard pollution
in <sys/param.h>.

%   /usr/include/sys/cdefs.h /usr/include/machine/endian.h \
%   /usr/include/x86/endian.h /usr/include/sys/_types.h \
%   /usr/include/machine/_types.h /usr/include/x86/_types.h \
%   /usr/include/sys/_pthreadtypes.h /usr/include/sys/_stdint.h \
%   /usr/include/sys/select.h /usr/include/sys/_sigset.h \
     ^^^^^^^^^^^^^^^^^^^^^^^^^

Standard pollution in <sys/types.h>.

%   /usr/include/sys/_timeval.h /usr/include/sys/timespec.h \
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Standard pollution in <sys/types.h>.

%   /usr/include/sys/_timespec.h /usr/include/sys/syslimits.h \
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%   /usr/include/sys/signal.h /usr/include/machine/_limits.h \
     ^^^^^^^^^^^^^^^^^^^^^^^^^

Standard pollutions in <sys/param.h>.

%   /usr/include/x86/_limits.h /usr/include/machine/signal.h \
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%   /usr/include/machine/trap.h /usr/include/x86/trap.h \
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^

Standard pollutions in <sys/signal.h> and thus in <sys/param.h>.

%   /usr/include/machine/param.h /usr/include/machine/_align.h \
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%   /usr/include/x86/_align.h /usr/include/sys/limits.h
                               ^^^^^^^^^^^^^^^^^^^^^^^^^

Standard pollutions in <sys/param.h>.

To remove a single header, you must know all the standard pollutions and
check cc -E -MM output to verify that no nonstandard pollutions are
depended on.

That was for <sys/mount.h>.  Now for some others.

> -#include <sys/param.h>
> -#include <sys/stat.h>
> #include <sys/file.h>

<sys/types.h> a is documented prerequisite for <sys/stat.h>.  It was
correct to get it via <sys/param.h>.  However, <sys/stat.h> is a POSIX
header.  POSIX required <sys/types.h> before <sys/stat.h> in 1988, but
removed this requirement in 2001 or before.  FreeBSD is slowly catching
up with this:
- FreeBSD <sys/stat.h> has always been massively polluted by including
   <sys/time.h> and all if its pollution (which includes <sys/types.h>.
   The polluting <sys/time.h> became unnecessary in about 1995 and is
   mostly fixed in my version (I include <sys/timespec.h> instead).
- FreeBSD man pages were originally very inconsistent about documenting
   the <sys/types.h> prereq.  It wasn't ever a prereq in FreeBSD, but was
   required for portability.  None documented this of course.
- At about the same time that POSIX removed the prereq, lots of man pages
   were "fixed" to document the old POSIX prereq.
- man pages (e.g., stat(2)) still document the old POSIX prereq.  More code
   than before probably doesn't satisfy this.

<sys/file.h> is documented as having no prereqs (in flock(2)).  It
satisfies this by polluting itself with <sys/types.h> and other
includes.  The pollution is not documented of course.

So this commit is correct for <sys/stat.h> and <sys/file.h> except it
depends on undocumented details for the former.

Bruce


More information about the svn-src-head mailing list