All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>,
	Sergio Lopez <slp@redhat.com>,
	qemu-devel@nongnu.org, Taylor Simpson <tsimpson@quicinc.com>,
	qemu-arm@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH for-7.0 0/4] qemu-common.h include cleanup
Date: Tue, 30 Nov 2021 11:02:47 +0100	[thread overview]
Message-ID: <87sfvenepk.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <CAFEAcA_ognVQ=7-pE+MDwkJCtcD0FfzPL0Vnb7vTgzbVSpnrLA@mail.gmail.com> (Peter Maydell's message of "Mon, 29 Nov 2021 20:48:08 +0000")

Peter Maydell <peter.maydell@linaro.org> writes:

> On Mon, 29 Nov 2021 at 20:05, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> qemu-common.h has a comment at the top:
>>
>>  * This file is supposed to be included only by .c files. No header file should
>>  * depend on qemu-common.h, as this would easily lead to circular header
>>  * dependencies.
>
> As a side note, that comment was added back in 2012 when qemu-common.h
> was bigger, included other headers, and did some of the work we currently
> use osdep.h for. As it stands today qemu-common.h includes no other
> files so it isn't a source of possible circular dependencies -- it's
> just a grab-bag of miscellaneous prototypes that in an ideal world
> would be in more focused individual headers[*]. So there's an argument
> for deleting this comment...

First, thank you for this cleanup series.

The comment is from commit 04509ad939a:

    qemu-common.h: Comment about usage rules
    
    Every time we make a tiny change on a header file, we often find
    circular header dependency problems. To avoid this nightmare, we need to
    stop including qemu-common.h from other headers, and we should gradually
    move the declarations from the catch-all qemu-common.h header to their
    specific headers.
    
    This simply adds a comment documenting the rules about qemu-common.h,
    hoping that people will see it before including qemu-common.h from other
    header files, and before adding more declarations to qemu-common.h.
    
    Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
    Signed-off-by: Andreas Färber <afaerber@suse.de>

You're right: we've since moved all #include out of qemu-common.h, so
the risk of circular header dependency is gone, and the comment's claim
"this would easily lead to circular header dependencies" is no longer
correct.

In my opinion, including qemu-common.h in a header is a bad idea
regardless.  Headers should include the headers they need to make them
self-contained, and no more, because more risks slower compiles, in
particular frequent recompiles of pretty much everything.  Previously
discussed at

    https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg06291.html
    Message-ID: <877eac82il.fsf@dusky.pond.sub.org>

Nothing in qemu-common.h should be required to make another header
self-contained.

This is likely the case for other headers as well, which don't carry a
comment forbidding inclusion into headers.  You could argue that
qemu-common.h should not carry one, either.  I can accept that.  I'm not
attached to the comment.  I am interested in keeping unwanted #include
in headers under control.

> [*] A cleanup that would be nice, and I'm about to send out a patchset
> that splits out the rtc related functions; but the grab-bag at the
> bottom of osdep.h is probably higher priority because that header
> gets pulled in by an order of magnitude more C files.

By all "normal" ones, in fact.


  reply	other threads:[~2021-11-30 10:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 20:05 [PATCH for-7.0 0/4] qemu-common.h include cleanup Peter Maydell
2021-11-29 20:05 ` Peter Maydell
2021-11-29 20:05 ` [PATCH for-7.0 1/4] include/hw/i386: Don't include qemu-common.h in .h files Peter Maydell
2021-11-29 20:05 ` [PATCH for-7.0 2/4] target/hexagon/cpu.h: don't include qemu-common.h Peter Maydell
2021-11-29 20:05   ` Peter Maydell
2021-12-07 16:55   ` Taylor Simpson
2021-12-07 16:55     ` Taylor Simpson
2021-11-29 20:05 ` [PATCH for-7.0 3/4] target/rx/cpu.h: Don't " Peter Maydell
2021-11-29 20:05   ` Peter Maydell
2021-12-01 12:26   ` Yoshinori Sato
2021-11-29 20:05 ` [PATCH for-7.0 4/4] hw/arm: Don't include qemu-common.h unnecessarily Peter Maydell
2021-11-29 20:05   ` Peter Maydell
2021-11-29 20:48 ` [PATCH for-7.0 0/4] qemu-common.h include cleanup Peter Maydell
2021-11-29 20:48   ` Peter Maydell
2021-11-30 10:02   ` Markus Armbruster [this message]
2021-11-30  8:40 ` Richard Henderson
2021-12-01 13:05 ` Philippe Mathieu-Daudé
2021-12-01 13:05   ` Philippe Mathieu-Daudé

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=87sfvenepk.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=slp@redhat.com \
    --cc=tsimpson@quicinc.com \
    --cc=ysato@users.sourceforge.jp \
    /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.