[PATCH 2/4] bsd-user: Clean up includes

Peter Maydell posted 4 patches 3 weeks ago
Maintainers: Magnus Kulke <magnus.kulke@linux.microsoft.com>, Wei Liu <wei.liu@kernel.org>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>, Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, "Michael S. Tsirkin" <mst@redhat.com>, Nicholas Piggin <npiggin@gmail.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Aditya Gupta <adityag@linux.ibm.com>, Sourabh Jain <sourabhjain@linux.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Laurent Vivier <laurent@vivier.eu>, Michael Roth <michael.roth@amd.com>, Kostiantyn Kostiuk <kkostiuk@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Marcelo Tosatti <mtosatti@redhat.com>, Song Gao <gaosong@loongson.cn>
[PATCH 2/4] bsd-user: Clean up includes
Posted by Peter Maydell 3 weeks ago
This commit was created with scripts/clean-includes:
 ./scripts/clean-includes '--git' 'bsd-user' 'bsd-user'

All .c should include qemu/osdep.h first.  The script performs three
related cleanups:

* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c  already includes
  it.  Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant.
  Drop these, too.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 bsd-user/bsd-mem.h         | 3 ---
 bsd-user/bsd-proc.c        | 1 -
 bsd-user/freebsd/os-proc.h | 2 --
 bsd-user/qemu-bsd.h        | 1 -
 4 files changed, 7 deletions(-)

diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
index 416d0f8c23..a118e57260 100644
--- a/bsd-user/bsd-mem.h
+++ b/bsd-user/bsd-mem.h
@@ -49,11 +49,8 @@
 #ifndef BSD_USER_BSD_MEM_H
 #define BSD_USER_BSD_MEM_H
 
-#include <sys/types.h>
 #include <sys/ipc.h>
-#include <sys/mman.h>
 #include <sys/shm.h>
-#include <fcntl.h>
 
 #include "qemu-bsd.h"
 #include "exec/mmap-lock.h"
diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
index ca3c1bf94f..8dcac9608d 100644
--- a/bsd-user/bsd-proc.c
+++ b/bsd-user/bsd-proc.c
@@ -19,7 +19,6 @@
 #include "qemu/osdep.h"
 
 #include <sys/param.h>
-#include <sys/types.h>
 #include <sys/cpuset.h>
 #include <sys/resource.h>
 #include <sys/wait.h>
diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h
index 3003c8cb63..cc53215138 100644
--- a/bsd-user/freebsd/os-proc.h
+++ b/bsd-user/freebsd/os-proc.h
@@ -23,10 +23,8 @@
 #include <sys/param.h>
 #include <sys/procctl.h>
 #include <sys/signal.h>
-#include <sys/types.h>
 #include <sys/procdesc.h>
 #include <sys/wait.h>
-#include <unistd.h>
 
 #include "target_arch_cpu.h"
 
diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h
index ffc64bb244..56affcd31d 100644
--- a/bsd-user/qemu-bsd.h
+++ b/bsd-user/qemu-bsd.h
@@ -20,7 +20,6 @@
 #ifndef QEMU_BSD_H
 #define QEMU_BSD_H
 
-#include <sys/types.h>
 #include <sys/resource.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
-- 
2.47.3
Re: [PATCH 2/4] bsd-user: Clean up includes
Posted by Warner Losh 3 weeks ago
On Fri, Jan 16, 2026 at 5:58 AM Peter Maydell <peter.maydell@linaro.org>
wrote:

> This commit was created with scripts/clean-includes:
>  ./scripts/clean-includes '--git' 'bsd-user' 'bsd-user'
>
> All .c should include qemu/osdep.h first.  The script performs three
> related cleanups:
>
> * Ensure .c files include qemu/osdep.h first.
> * Including it in a .h is redundant, since the .c  already includes
>   it.  Drop such inclusions.
> * Likewise, including headers qemu/osdep.h includes is redundant.
>   Drop these, too.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  bsd-user/bsd-mem.h         | 3 ---
>  bsd-user/bsd-proc.c        | 1 -
>  bsd-user/freebsd/os-proc.h | 2 --
>  bsd-user/qemu-bsd.h        | 1 -
>  4 files changed, 7 deletions(-)
>

Reviewed-by: Warner Losh <imp@bsdimp.com>

These were the documented includes needed for these APIs. But this cleanup
is fine.
We weren't 100% consistent anyway before.


> diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
> index 416d0f8c23..a118e57260 100644
> --- a/bsd-user/bsd-mem.h
> +++ b/bsd-user/bsd-mem.h
> @@ -49,11 +49,8 @@
>  #ifndef BSD_USER_BSD_MEM_H
>  #define BSD_USER_BSD_MEM_H
>
> -#include <sys/types.h>
>  #include <sys/ipc.h>
> -#include <sys/mman.h>
>  #include <sys/shm.h>
> -#include <fcntl.h>
>
>  #include "qemu-bsd.h"
>  #include "exec/mmap-lock.h"
> diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
> index ca3c1bf94f..8dcac9608d 100644
> --- a/bsd-user/bsd-proc.c
> +++ b/bsd-user/bsd-proc.c
> @@ -19,7 +19,6 @@
>  #include "qemu/osdep.h"
>
>  #include <sys/param.h>
> -#include <sys/types.h>
>  #include <sys/cpuset.h>
>  #include <sys/resource.h>
>  #include <sys/wait.h>
> diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h
> index 3003c8cb63..cc53215138 100644
> --- a/bsd-user/freebsd/os-proc.h
> +++ b/bsd-user/freebsd/os-proc.h
> @@ -23,10 +23,8 @@
>  #include <sys/param.h>
>  #include <sys/procctl.h>
>  #include <sys/signal.h>
> -#include <sys/types.h>
>  #include <sys/procdesc.h>
>  #include <sys/wait.h>
> -#include <unistd.h>
>
>  #include "target_arch_cpu.h"
>
> diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h
> index ffc64bb244..56affcd31d 100644
> --- a/bsd-user/qemu-bsd.h
> +++ b/bsd-user/qemu-bsd.h
> @@ -20,7 +20,6 @@
>  #ifndef QEMU_BSD_H
>  #define QEMU_BSD_H
>
> -#include <sys/types.h>
>  #include <sys/resource.h>
>  #include <sys/ipc.h>
>  #include <sys/msg.h>
> --
> 2.47.3
>
>
Re: [PATCH 2/4] bsd-user: Clean up includes
Posted by Philippe Mathieu-Daudé 3 weeks ago
On 16/1/26 13:58, Peter Maydell wrote:
> This commit was created with scripts/clean-includes:
>   ./scripts/clean-includes '--git' 'bsd-user' 'bsd-user'
> 
> All .c should include qemu/osdep.h first.  The script performs three
> related cleanups:
> 
> * Ensure .c files include qemu/osdep.h first.
> * Including it in a .h is redundant, since the .c  already includes
>    it.  Drop such inclusions.
> * Likewise, including headers qemu/osdep.h includes is redundant.
>    Drop these, too.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   bsd-user/bsd-mem.h         | 3 ---
>   bsd-user/bsd-proc.c        | 1 -
>   bsd-user/freebsd/os-proc.h | 2 --
>   bsd-user/qemu-bsd.h        | 1 -
>   4 files changed, 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>