Re: Missing include in sys/device.h

2021-09-28 Thread Ingo Schwarze
Hi Rafael,

Rafael Sadowski wrote on Tue, Sep 28, 2021 at 08:22:06AM +0200:
> On Mon Sep 27, 2021 at 11:20:55PM -0600, Theo de Raadt wrote:

>> Oh, like how about you try compiling a kernel after your proposed diff?
>> 
>> in userland -
>>size_t comes from sys/types.h
>>or a header file which pulls in sys/types.h, and there should be
>>no further new iteration added
>> 
>> in kernel -
>> size_t comes from either sys/param.h or sys/types.h, depending
>> on which one a file includes
>> 
>> What you are suggesting is completely crazy.  It's akin to "all
>> header files should include all other dependent header files, and
>> hey maybe one day we can have a #include_all directive, eh?
>> 
>> Absolutely no way.

> Totally understandable! I have to get used with the userland/kernel
> src-environment. Thanks for the explanation and sorry for the noise.

By the way: some userland programs (but not all userland programs, and
of course not the C library) use the same rule of thumb that "headers
usually do not include headers".

Some will likely regard the following level of documentation excessive,
and i'm certainly not proposing to do this in more places.  But it does
help me personally to not lose track of what provides and uses what
in a program with a large number of deeply nested data structures and
a considerable number of modules that are in part independent of each
other and in part call the internal APIs of the next-lower layer:

  https://mandoc.bsd.lv/man/mandoc_headers.3.html

Making sure that not everything includes everything also helps to
recognize layering violation design errors early on, usually near
the beginning of the implementation phase of a new feature, sometimes
before any code starts being written at all.

Yours,
  Ingo



Re: Missing include in sys/device.h

2021-09-28 Thread Rafael Sadowski
On Mon Sep 27, 2021 at 11:20:55PM -0600, Theo de Raadt wrote:
> Oh, like how about you try compiling a kernel after your proposed diff?
> 
> in userland -
>size_t comes from sys/types.h
>or a header file which pulls in sys/types.h, and there should be
>no further new iteration added
> 
> in kernel -
> size_t comes from either sys/param.h or sys/types.h, depending
> on which one a file includes
> 
> What you are suggesting is completely crazy.  It's akin to "all
> header files should include all other dependent header files, and
> hey maybe one day we can have a #include_all directive, eh?
> 
> Absolutely no way.
> 

Totally understandable! I have to get used with the userland/kernel src-
environment. Thanks for the explanation and sorry for the noise.



Re: Missing include in sys/device.h

2021-09-27 Thread Theo de Raadt
Oh, like how about you try compiling a kernel after your proposed diff?

in userland -
   size_t comes from sys/types.h
   or a header file which pulls in sys/types.h, and there should be
   no further new iteration added

in kernel -
size_t comes from either sys/param.h or sys/types.h, depending
on which one a file includes

What you are suggesting is completely crazy.  It's akin to "all
header files should include all other dependent header files, and
hey maybe one day we can have a #include_all directive, eh?

Absolutely no way.

Rafael Sadowski  wrote:

> device.h misses a definition of size_t
> 
> /usr/include/sys/device.h:128:2: error: unknown type name 'size_t'
> 
> Index: device.h
> ===
> RCS file: /cvs/src/sys/sys/device.h,v
> retrieving revision 1.55
> diff -u -p -r1.55 device.h
> --- device.h  10 Sep 2018 16:18:34 -  1.55
> +++ device.h  28 Sep 2021 05:04:57 -
> @@ -44,6 +44,8 @@
>  #ifndef _SYS_DEVICE_H_
>  #define  _SYS_DEVICE_H_
>  
> +#include 
> +
>  #include 
>  
>  /*
> 



Missing include in sys/device.h

2021-09-27 Thread Rafael Sadowski
device.h misses a definition of size_t

/usr/include/sys/device.h:128:2: error: unknown type name 'size_t'

Index: device.h
===
RCS file: /cvs/src/sys/sys/device.h,v
retrieving revision 1.55
diff -u -p -r1.55 device.h
--- device.h10 Sep 2018 16:18:34 -  1.55
+++ device.h28 Sep 2021 05:04:57 -
@@ -44,6 +44,8 @@
 #ifndef _SYS_DEVICE_H_
 #define_SYS_DEVICE_H_
 
+#include 
+
 #include 
 
 /*