qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Warner Losh <imp@bsdimp.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org,
	pbonzini@redhat.com,  kwolf@redhat.com, hreitz@redhat.com,
	kevans@freebsd.org, berrange@redhat.com,  groug@kaod.org,
	qemu_oss@crudebyte.com, mst@redhat.com, philmd@linaro.org,
	 peter.maydell@linaro.org, alistair@alistair23.me,
	jasowang@redhat.com,  jonathan.cameron@huawei.com,
	kbastian@mail.uni-paderborn.de,  quintela@redhat.com,
	dgilbert@redhat.com, michael.roth@amd.com,  kkostiuk@redhat.com,
	tsimpson@quicinc.com, palmer@dabbelt.com,
	 bin.meng@windriver.com, qemu-block@nongnu.org,
	qemu-arm@nongnu.org,  qemu-riscv@nongnu.org
Subject: Re: [PATCH v4 04/19] bsd-user: Clean up includes
Date: Thu, 19 Jan 2023 10:05:01 -0700	[thread overview]
Message-ID: <CANCZdfrLF6Lecrd9VLTu-iDGWFCUJRM1veMejE2oX3ZAVEMBjg@mail.gmail.com> (raw)
In-Reply-To: <87r0vqpjbt.fsf@pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 8514 bytes --]

On Thu, Jan 19, 2023 at 9:42 AM Markus Armbruster <armbru@redhat.com> wrote:

> Warner Losh <imp@bsdimp.com> writes:
>
> > On Thu, Jan 19, 2023 at 12:00 AM Markus Armbruster <armbru@redhat.com>
> > wrote:
> >
> >> Clean up includes so that osdep.h is included first and headers
> >> which it implies are not included manually.
> >>
> >> This commit was created with scripts/clean-includes.
> >>
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> ---
> >>  bsd-user/bsd-proc.h               | 4 ----
> >>  bsd-user/qemu.h                   | 1 -
> >>  bsd-user/arm/signal.c             | 1 +
> >>  bsd-user/arm/target_arch_cpu.c    | 2 ++
> >>  bsd-user/freebsd/os-sys.c         | 1 +
> >>  bsd-user/i386/signal.c            | 1 +
> >>  bsd-user/i386/target_arch_cpu.c   | 3 +--
> >>  bsd-user/main.c                   | 4 +---
> >>  bsd-user/strace.c                 | 1 -
> >>  bsd-user/x86_64/signal.c          | 1 +
> >>  bsd-user/x86_64/target_arch_cpu.c | 3 +--
> >>  11 files changed, 9 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h
> >> index 68b66e571d..a1061bffb8 100644
> >> --- a/bsd-user/bsd-proc.h
> >> +++ b/bsd-user/bsd-proc.h
> >> @@ -20,11 +20,7 @@
> >>  #ifndef BSD_PROC_H_
> >>  #define BSD_PROC_H_
> >>
> >> -#include <sys/types.h>
> >> -#include <sys/stat.h>
> >> -#include <sys/time.h>
> >>  #include <sys/resource.h>
> >>
> >
> > Did you test this on FreeBSD 12? FreeBSD 13 has started to climb the hill
> > where all includes are independent, but much of that hasn't been merged
> to
> > 12 yet. sys/types.h, at least, is documented as a prereq for both
> > sys/stat.h and sys/resource.h.
> >
> > I know many of these are in os-dep.h, and I've had trouble in the
> bsd-user
> > fork with that and the layout of the code which has arguably way too much
> > in the .h files.
>
> No, I didn't test on FreeBSD 12.
>

OK. Fair enough. If it passes the CI tests, then it's likely fine (though
if I hit issues, I'll submit patches).


> Any .c must include qemu/osdep.h *first*.  Any further inclusions of
> headers qemu/osdep.h includes already are no-ops unless the headers in
> question lack multiple inclusion guards.
>

OK.


> > Also, why didn't you move sys/resource.h and other such files to
> os-dep.h?
> > I'm struggling to understand the rules around what is or isn't included
> > where?
>
> This series is "run scripts/clean-includes, split it into reviewable
> chunks, tidy up blank lines".  Moving more includes into qemu/osdep.h is
> out of scope.
>

OK. Fair point. I'm happy with that answer since it tells me I could move
things there too, if need be.


> I sympathize with your complaint that QEMU does too much in headers in
> general, and in qemu/osdep.h in particular.
>

Yea, I'm not entirely sure  it's a complaint, or if it's an observation of
difficulties relative to other code bases... I go back and forth on my
opinion of it...


> >> -#include <unistd.h>
> >>
> >>  /* exit(2) */
> >>  static inline abi_long do_bsd_exit(void *cpu_env, abi_long arg1)
> >> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> >> index be6105385e..0ceecfb6df 100644
> >> --- a/bsd-user/qemu.h
> >> +++ b/bsd-user/qemu.h
> >> @@ -17,7 +17,6 @@
> >>  #ifndef QEMU_H
> >>  #define QEMU_H
> >>
> >> -#include "qemu/osdep.h"
> >>  #include "cpu.h"
> >>  #include "qemu/units.h"
> >>  #include "exec/cpu_ldst.h"
> >> diff --git a/bsd-user/arm/signal.c b/bsd-user/arm/signal.c
> >> index 2b1dd745d1..9734407543 100644
> >> --- a/bsd-user/arm/signal.c
> >> +++ b/bsd-user/arm/signal.c
> >> @@ -17,6 +17,7 @@
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >>
> >> +#include "qemu/osdep.h"
> >>  #include "qemu.h"
> >>
> >>  /*
> >> diff --git a/bsd-user/arm/target_arch_cpu.c
> >> b/bsd-user/arm/target_arch_cpu.c
> >> index 02bf9149d5..fe38ae2210 100644
> >> --- a/bsd-user/arm/target_arch_cpu.c
> >> +++ b/bsd-user/arm/target_arch_cpu.c
> >> @@ -16,6 +16,8 @@
> >>   *  You should have received a copy of the GNU General Public License
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >> +
> >> +#include "qemu/osdep.h"
> >>  #include "target_arch.h"
> >>
> >>  void target_cpu_set_tls(CPUARMState *env, target_ulong newtls)
> >> diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c
> >> index 309e27b9d6..1676ec10f8 100644
> >> --- a/bsd-user/freebsd/os-sys.c
> >> +++ b/bsd-user/freebsd/os-sys.c
> >> @@ -17,6 +17,7 @@
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >>
> >> +#include "qemu/osdep.h"
> >>  #include "qemu.h"
> >>  #include "target_arch_sysarch.h"
> >>
> >> diff --git a/bsd-user/i386/signal.c b/bsd-user/i386/signal.c
> >> index 5dd975ce56..a3131047b8 100644
> >> --- a/bsd-user/i386/signal.c
> >> +++ b/bsd-user/i386/signal.c
> >> @@ -17,6 +17,7 @@
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >>
> >> +#include "qemu/osdep.h"
> >>  #include "qemu.h"
> >>
> >>  /*
> >> diff --git a/bsd-user/i386/target_arch_cpu.c
> >> b/bsd-user/i386/target_arch_cpu.c
> >> index d349e45299..2a3af2ddef 100644
> >> --- a/bsd-user/i386/target_arch_cpu.c
> >> +++ b/bsd-user/i386/target_arch_cpu.c
> >> @@ -17,9 +17,8 @@
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >>
> >> -#include <sys/types.h>
> >> -
> >>  #include "qemu/osdep.h"
> >> +
> >>  #include "cpu.h"
> >>  #include "qemu.h"
> >>  #include "qemu/timer.h"
> >> diff --git a/bsd-user/main.c b/bsd-user/main.c
> >> index 6f09180d65..41290e16f9 100644
> >> --- a/bsd-user/main.c
> >> +++ b/bsd-user/main.c
> >> @@ -18,12 +18,10 @@
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >>
> >> -#include <sys/types.h>
> >> -#include <sys/time.h>
> >> +#include "qemu/osdep.h"
> >>  #include <sys/resource.h>
> >>  #include <sys/sysctl.h>
> >>
> >> -#include "qemu/osdep.h"
> >>  #include "qemu/help-texts.h"
> >>  #include "qemu/units.h"
> >>  #include "qemu/accel.h"
> >> diff --git a/bsd-user/strace.c b/bsd-user/strace.c
> >> index a77d10dd6b..96499751eb 100644
> >> --- a/bsd-user/strace.c
> >> +++ b/bsd-user/strace.c
> >> @@ -20,7 +20,6 @@
> >>  #include <sys/select.h>
> >>  #include <sys/syscall.h>
> >>  #include <sys/ioccom.h>
> >> -#include <ctype.h>
> >>
> >>  #include "qemu.h"
> >>
> >> diff --git a/bsd-user/x86_64/signal.c b/bsd-user/x86_64/signal.c
> >> index c3875bc4c6..46cb865180 100644
> >> --- a/bsd-user/x86_64/signal.c
> >> +++ b/bsd-user/x86_64/signal.c
> >> @@ -16,6 +16,7 @@
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >>
> >> +#include "qemu/osdep.h"
> >>  #include "qemu.h"
> >>
> >>  /*
> >> diff --git a/bsd-user/x86_64/target_arch_cpu.c
> >> b/bsd-user/x86_64/target_arch_cpu.c
> >> index be7bd10720..1d32f18907 100644
> >> --- a/bsd-user/x86_64/target_arch_cpu.c
> >> +++ b/bsd-user/x86_64/target_arch_cpu.c
> >> @@ -17,9 +17,8 @@
> >>   *  along with this program; if not, see <http://www.gnu.org/licenses/
> >.
> >>   */
> >>
> >> -#include <sys/types.h>
> >> -
> >>  #include "qemu/osdep.h"
> >> +
> >>  #include "cpu.h"
> >>  #include "qemu.h"
> >>  #include "qemu/timer.h"
> >>
> >
> > I suppose these are fine. How do I run the cleanup script? I have 2x the
> > number of files not upstream in the bsd-user fork that I'd like to
> cleanup
> > as well and they are likely a bigger mess and I'll just upstream them in
> > the messy state unless I understand how to keep the neat :).
>
> I used
>
>     $ scripts/clean-includes --check-dup-head --all
>
> Which resulted in a big mess I didn't dare to submit for review :)  So I
> split it up.  Easiest way was to identify useful sets of files, add
> files that include headers from the set, transitively, then run
>
>     $ scripts/clean-includes FILES...
>
> --check-dup-head reports possible duplicate inclusions.  It is prone to
> false positives.  That's why it merely reports them.  You may want to
> not use it for now.
>
> There's a big usage comment at the beginning of the script.
>
> Hope this helps!
>

It does. After your changes land, I'll merge, and run this on the branch. I
have a few changes queued up, and have been contemplating changes to my
upstreaming workflow to speed the process along...

So I'm happy with it. Thanks for the cleanup and the time to answer my
questions.

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

Warner

[-- Attachment #2: Type: text/html, Size: 12849 bytes --]

  reply	other threads:[~2023-01-19 17:06 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19  6:59 [PATCH v4 00/19] Clean up includes Markus Armbruster
2023-01-19  6:59 ` [PATCH v4 01/19] scripts/clean-includes: Fully skip / ignore files Markus Armbruster
2023-01-27 21:29   ` Eric Blake
2023-01-28 10:28   ` Michael S. Tsirkin
2023-01-30 12:55     ` Markus Armbruster
2023-01-19  6:59 ` [PATCH v4 02/19] scripts/clean-includes: Don't claim duplicate headers found when not Markus Armbruster
2023-01-27 21:38   ` Eric Blake
2023-01-19  6:59 ` [PATCH v4 03/19] scripts/clean-includes: Skip symbolic links Markus Armbruster
2023-01-27 22:47   ` Eric Blake
2023-01-27 23:08     ` Warner Losh
2023-01-19  6:59 ` [PATCH v4 04/19] bsd-user: Clean up includes Markus Armbruster
2023-01-19 14:42   ` Warner Losh
2023-01-19 16:42     ` Markus Armbruster
2023-01-19 17:05       ` Warner Losh [this message]
2023-01-27 12:01         ` Markus Armbruster
2023-01-27 14:54     ` Peter Maydell
2023-01-27 15:01       ` Michael S. Tsirkin
2023-01-28 10:29         ` Michael S. Tsirkin
2023-01-30 13:12           ` Markus Armbruster
2023-01-19  6:59 ` [PATCH v4 05/19] crypto: " Markus Armbruster
2023-01-19 10:34   ` Philippe Mathieu-Daudé
2023-01-19  6:59 ` [PATCH v4 06/19] hw/cxl: " Markus Armbruster
2023-01-19  6:59 ` [PATCH v4 07/19] hw/input: " Markus Armbruster
2023-01-19  6:59 ` [PATCH v4 08/19] hw/tricore: " Markus Armbruster
2023-01-19 10:34   ` Philippe Mathieu-Daudé
2023-01-19  6:59 ` [PATCH v4 09/19] qga: " Markus Armbruster
2023-01-19  8:30   ` Konstantin Kostiuk
2023-01-19  6:59 ` [PATCH v4 10/19] migration: " Markus Armbruster
2023-01-19  9:34   ` Dr. David Alan Gilbert
2023-01-19 10:31     ` Markus Armbruster
2023-01-19 11:45       ` Dr. David Alan Gilbert
2023-01-20  7:19         ` Markus Armbruster
2023-01-30  4:11           ` Juan Quintela
2023-01-19  6:59 ` [PATCH v4 11/19] net: " Markus Armbruster
2023-01-19 10:35   ` Philippe Mathieu-Daudé
2023-01-19  6:59 ` [PATCH v4 12/19] target/hexagon: " Markus Armbruster
2023-01-19 22:15   ` Taylor Simpson
2023-01-20  7:21     ` Markus Armbruster
2023-01-19  6:59 ` [PATCH v4 13/19] riscv: " Markus Armbruster
2023-01-19 10:38   ` Philippe Mathieu-Daudé
2023-01-19 22:44   ` Alistair Francis
2023-01-19  6:59 ` [PATCH v4 14/19] block: " Markus Armbruster
2023-01-27 22:55   ` Eric Blake
2023-01-19  6:59 ` [PATCH v4 15/19] accel: " Markus Armbruster
2023-01-19 10:36   ` Philippe Mathieu-Daudé
2023-01-19  6:59 ` [PATCH v4 16/19] Fix non-first inclusions of qemu/osdep.h Markus Armbruster
2023-01-19 10:40   ` Philippe Mathieu-Daudé
2023-01-19 11:41     ` Markus Armbruster
2023-01-19 11:52       ` Philippe Mathieu-Daudé
2023-01-19 12:40         ` Markus Armbruster
2023-01-27 12:05         ` Markus Armbruster
2023-01-30  4:13   ` Juan Quintela
2023-01-19  6:59 ` [PATCH v4 17/19] Don't include headers already included by qemu/osdep.h Markus Armbruster
2023-01-19 12:06   ` Christian Schoenebeck
2023-01-19  6:59 ` [PATCH v4 18/19] 9p: Drop superfluous include of linux/limits.h Markus Armbruster
2023-01-19  9:50   ` Christian Schoenebeck
2023-01-19 10:37     ` Markus Armbruster
2023-01-19 12:01       ` Christian Schoenebeck
2023-01-19  6:59 ` [PATCH v4 19/19] Drop duplicate #include Markus Armbruster
2023-01-19 10:19   ` Dr. David Alan Gilbert
2023-01-19 14:17   ` Greg Kurz
2023-01-30  4:16   ` Juan Quintela
2023-01-19  9:20 ` [PATCH v4 00/19] Clean up includes Markus Armbruster
2023-01-19 11:49 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANCZdfrLF6Lecrd9VLTu-iDGWFCUJRM1veMejE2oX3ZAVEMBjg@mail.gmail.com \
    --to=imp@bsdimp.com \
    --cc=alistair@alistair23.me \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=bin.meng@windriver.com \
    --cc=dgilbert@redhat.com \
    --cc=groug@kaod.org \
    --cc=hreitz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=kevans@freebsd.org \
    --cc=kkostiuk@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=mst@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=quintela@redhat.com \
    --cc=richard.henderson@linaro.org \
    --cc=tsimpson@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).