qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-trivial@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH 2/4] Do not include hw/boards.h if it's not really necessary
Date: Sat, 17 Apr 2021 11:50:11 +0200	[thread overview]
Message-ID: <87o8ed1bqk.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <f877e682-7c9b-26d8-1ef5-b22b268bb29e@redhat.com> (Thomas Huth's message of "Fri, 16 Apr 2021 20:04:48 +0200")

Thomas Huth <thuth@redhat.com> writes:

> On 16/04/2021 19.53, Philippe Mathieu-Daudé wrote:
>> Hi Thomas,
>> On 4/16/21 7:13 PM, Thomas Huth wrote:
>>> Stop including hw/boards.h in files that don't need it.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>>   accel/tcg/tcg-accel-ops-icount.c | 1 -
>>>   accel/tcg/tcg-accel-ops-rr.c     | 1 -
>>>   accel/tcg/tcg-accel-ops.c        | 1 -
>>>   hw/acpi/cpu.c                    | 1 -
>>>   hw/acpi/memory_hotplug.c         | 1 -
>>>   hw/alpha/typhoon.c               | 1 -
>>>   hw/arm/aspeed.c                  | 1 -
>> It requires the macros declared by:
>> OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE)
>
> "hw/boards.h" is already included in include/hw/arm/aspeed.h, that's
> why it's working ... Hmm, do we have a policy whether a header should
> be included again in the .c file if it's already included by a .h
> file?

I'm not aware of a formal policy.

The most common "method" for dealing with #include is probably "when the
compiler demands declarations, throw #include at it until it shuts up".

This "method" only ever adds, never deletes.  It can easily lead to
including headers many times, and to including headers unnecessarily.

Including many times isn't much of a problem in practice.  A
sufficiently smart C compiler should be able to skip #include of a
"safe" header it has already seen, so redundant #include should not slow
down the build noticeably.  I prefer to avoid / delete obviously
duplicate inclusions anyway.

Including unnecessarily *is* a problem.  A massive one.  But it's not
what you asked about.

[...]



  reply	other threads:[~2021-04-17  9:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 17:13 [PATCH for-6.1 0/4] Remove more superfluous include statements Thomas Huth
2021-04-16 17:13 ` [PATCH 1/4] Do not include sysemu/sysemu.h if it's not really necessary Thomas Huth
2021-04-30 15:59   ` Laurent Vivier
2021-04-16 17:13 ` [PATCH 2/4] Do not include hw/boards.h " Thomas Huth
2021-04-16 17:53   ` Philippe Mathieu-Daudé
2021-04-16 18:04     ` Thomas Huth
2021-04-17  9:50       ` Markus Armbruster [this message]
2021-04-30 15:59   ` Laurent Vivier
2021-04-16 17:13 ` [PATCH 3/4] Do not include cpu.h " Thomas Huth
2021-04-30 15:59   ` Laurent Vivier
2021-04-16 17:13 ` [PATCH 4/4] Do not include exec/address-spaces.h " Thomas Huth
2021-04-30 15:59   ` Laurent Vivier

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=87o8ed1bqk.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.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).