All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	qemu-devel@nongnu.org, imp@bsdimp.com, kevans@freebsd.org,
	ben.widawsky@intel.com, jonathan.cameron@huawei.com,
	kbastian@mail.uni-paderborn.de, jasowang@redhat.com,
	michael.roth@amd.com, kkostiuk@redhat.com, tsimpson@quicinc.com,
	palmer@dabbelt.com, alistair.francis@wdc.com,
	bin.meng@windriver.com, qemu-riscv@nongnu.org, philmd@linaro.org,
	"Bin Meng" <bmeng.cn@gmail.com>
Subject: Re: [PATCH v3 1/1] include: Don't include qemu/osdep.h
Date: Thu, 12 Jan 2023 12:43:23 -0500	[thread overview]
Message-ID: <20230112124239-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAFEAcA9REU2emdHRhfO2=ZZB3K9O=eKSP1k5aVh_Hwh0+cCW5w@mail.gmail.com>

On Thu, Jan 12, 2023 at 03:58:56PM +0000, Peter Maydell wrote:
> On Thu, 12 Jan 2023 at 15:14, Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Thu, Jan 12, 2023 at 08:51:26AM -0500, Michael S. Tsirkin wrote:
> > > On Thu, Jan 12, 2023 at 12:50:05PM +0100, Markus Armbruster wrote:
> > > > docs/devel/style.rst mandates:
> > > >
> > > >     The "qemu/osdep.h" header contains preprocessor macros that affect
> > > >     the behavior of core system headers like <stdint.h>.  It must be
> > > >     the first include so that core system headers included by external
> > > >     libraries get the preprocessor macros that QEMU depends on.
> > > >
> > > >     Do not include "qemu/osdep.h" from header files since the .c file
> > > >     will have already included it.
> > > >
> > > > A few violations have crept in.  Fix them.
> > > >
> > > > Signed-off-by: Markus Armbruster <armbru@redhat.com>
> > > > Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > > > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> > > > Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
> > > > Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
> > >
> > > With my awesome grep skillz I found one more:
> > > $ grep -r --include='*.h' qemu/osdep.h
> > > include/block/graph-lock.h:#include "qemu/osdep.h"
> > >
> > > Looks like all C files must include qemu/osdep.h, no?
> >
> > Yes, and IMHO that is/was a mistake, as it means our other header
> > files are not self-contained, which prevents developer tools from
> > reporting useful bugs when you're editting.
> 
> The underlying requirement is "osdep.h must be included
> before any system header file". "Always first in every .c file"
> is an easy way to achieve that, and "never in any .h file" is
> then not mandatory but falls out from the fact that any
> such include is pointless and only serves to increase
> the compilation time (and to increase the chances that
> you don't notice that you forgot osdep.h in your .c file).
> 
> If there's a better way to do this (e.g. one which meant
> that it was a compile error to put osdep includes in the
> wrong place or to omit them) then that would certainly
> save us periodically having to do this kind of fixup commit.
> 
> thanks
> -- PMM

yes I just posted a patch that will catch most (though not all)
such cases. if we switch to -include it will catch all of them
but there seems to be some resistance to this idea.



  parent reply	other threads:[~2023-01-12 17:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 11:50 [PATCH v3 0/1] Clean up includes Markus Armbruster
2023-01-12 11:50 ` [PATCH v3 1/1] include: Don't include qemu/osdep.h Markus Armbruster
2023-01-12 13:51   ` Michael S. Tsirkin
2023-01-12 13:56     ` Michael S. Tsirkin
2023-01-12 14:47       ` Markus Armbruster
2023-01-12 17:37         ` Michael S. Tsirkin
2023-01-12 17:44           ` Daniel P. Berrangé
2023-01-12 17:47             ` Michael S. Tsirkin
2023-01-12 14:52     ` Daniel P. Berrangé
2023-01-12 15:58       ` Peter Maydell
2023-01-12 16:07         ` Daniel P. Berrangé
2023-01-12 16:20           ` Peter Maydell
2023-01-12 16:30             ` Daniel P. Berrangé
2023-01-12 16:38               ` Peter Maydell
2023-01-12 17:43         ` Michael S. Tsirkin [this message]
2023-01-12 17:30   ` Jonathan Cameron
2023-01-12 17:30     ` Jonathan Cameron via
2023-01-12 17:41   ` 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=20230112124239-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=armbru@redhat.com \
    --cc=ben.widawsky@intel.com \
    --cc=berrange@redhat.com \
    --cc=bin.meng@windriver.com \
    --cc=bmeng.cn@gmail.com \
    --cc=imp@bsdimp.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=michael.roth@amd.com \
    --cc=palmer@dabbelt.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.