svn commit: r349459 - head/sys/sys

Bruce Evans brde at optusnet.com.au
Thu Jun 27 17:38:08 UTC 2019


On Thu, 27 Jun 2019, Andriy Gapon wrote:

> On 27/06/2019 18:47, Bruce Evans wrote:
>> On Thu, 27 Jun 2019, Andriy Gapon wrote:
>>
>>> Log:
>>>  upgrade the warning printf-s in bus accessors to KASSERT-s
>>>
>>>  After this change sys/bus.h includes sys/systm.h.
>>
>> This is further namespace pollution.  sys/systm.h is a prerequiste for
>> all kernel headers except sys/param.h and the headers that that includes,
>> since any kernel header (except sys/param.hm etc.) may have inlines which
>> use features in systm.h, e.g., KASSERT() or an inline function.
>
> what do you think about amending style(9) to require that if sys/systm.h is to
> be included, then it must be included before any other header except for
> sys/param.h (and possibly sys/cdefs.h) ?

It is not a style matter.  sys/systm.h is just a prerequisite for almost
all kernel code.  Perhaps this can be enforced using #ifdef magic even
for headers that don't currently use it.  If it is to be included nested,
then sys/param.h is the place to include it, but I don't like that since
it is even less related to parameters than sys/param.h, and this would be
a regression from minor depollution of sys/param.h.

sys/systm.h is also kernel-only, and as you found, including it nested
tends to break applications, so other headers that have the bug of
including it tend to have _KERNEL ifdefs to avoid including it in
applications.  This is so fundamental that it doesn't have a "No
user-serviceable parts inside" ifdef.

Bruce


More information about the svn-src-all mailing list