qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Why do we typedef every struct on QEMU?
Date: Thu, 19 Jul 2018 10:18:22 +0200	[thread overview]
Message-ID: <c00a41f7-65eb-646a-73e4-2424140d04fb@redhat.com> (raw)
In-Reply-To: <87a7qnk9qa.fsf@dusky.pond.sub.org>

On 19.07.2018 08:42, Markus Armbruster wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
> 
>> On 17 July 2018 at 20:50, Eduardo Habkost <ehabkost@redhat.com> wrote:
>>> I have been looking at patches that touch typedefs.h and
>>> wondering: why do we make typedefs.h necessary at all?  Why do we
>>> always add typedefs for every struct and union type in QEMU?
>>>
>>> Why do we prefer to write this:
>>>
>>> ----- qemu/typedefs.h:
>>> typedef struct SomeType SomeType;
>>> ----------------------
>>>
>>> ----- qemu/somecode.h:
>>> #include <qemu/typedefs.h>
>>>
>>> int some_function(SomeType *a);
>>> ----------------------
>>>
>>>
>>> ...instead of simply writing this:?
>>>
>>> ----- qemu/somecode.h:
>>> struct SomeType;
>>> int some_function(struct SomeType *a);
>>> ----------------------
>>>
>>> Is the maintenance burden of typedefs.h worth it?
>>
>> Personally I don't like typing "struct " all the time
>> when I'm using the type...
> 
> For a different point of view (which I happen to share), see
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=024ddc0ce1049298bd3cae60ae45d9c5f0fb8b9c#n318

FWIW, as somebody who also has to write some kernel code occasionally,
I'd also prefer if we could get closer to the kernel coding style here
again.

That would also avoid problems like this that we used to hit regularly:

 https://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg02695.html

(well, that problem will likely go away automatically since we now don't
support these distros anymore, but still...)

 Thomas

  reply	other threads:[~2018-07-19  8:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 19:50 [Qemu-devel] Why do we typedef every struct on QEMU? Eduardo Habkost
2018-07-17 20:06 ` Peter Maydell
2018-07-19  6:42   ` Markus Armbruster
2018-07-19  8:18     ` Thomas Huth [this message]
2018-07-19  8:28     ` Paolo Bonzini
2018-07-27 13:03     ` Stefan Hajnoczi
2018-07-27 13:14       ` Daniel P. Berrangé
2018-07-27 13:16       ` Peter Maydell

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=c00a41f7-65eb-646a-73e4-2424140d04fb@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).