qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Andreas Faerber <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] qom: add style guide
Date: Mon, 13 Aug 2012 22:55:29 +0300	[thread overview]
Message-ID: <20120813195529.GC19139@redhat.com> (raw)
In-Reply-To: <1344883606-14854-1-git-send-email-aliguori@us.ibm.com>

On Mon, Aug 13, 2012 at 01:46:46PM -0500, Anthony Liguori wrote:
> +    typedef struct MyType MyType;
> +    
> +    struct MyType
> +    {

This seems to violate our style:should be

> +    struct MyType {



> +        Object parent_obj;
> +    
> +        /*< private >*/
> +        int foo;
> +    };
> +
> +When declaring the structure, a forward declaration should be used.  This is
> +useful for consistency sake as it is required when defining classes.
> +
> +The first element must be the parent type and should be named 'parent_obj' or
> +just 'parent'.

Why should it? Why not use a descriptive name that
makes it easier to see what the object actually is?

>  When working with QOM types, you should avoid ever accessing
> +this member directly instead relying on casting macros.
> +
> +Casting macros hide the inheritence hierarchy from the implementation.  This
> +makes it easier to refactor code over time by changing the hierarchy without
> +changing the code in many places.

This seems like a weak motivation. Why do you expect to refactor
hierarchy all the time?  The cost is replacing compile time checks with
runtime ones.

So refactoring is easier to make but harder to make correct.
Sounds like a bad tradeoff.

-- 
MST

  reply	other threads:[~2012-08-13 19:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-13 18:46 [Qemu-devel] [PATCH] qom: add style guide Anthony Liguori
2012-08-13 19:55 ` Michael S. Tsirkin [this message]
2012-08-13 20:57   ` Anthony Liguori
2012-08-13 21:57     ` Michael S. Tsirkin
2012-08-14  7:14 ` Jens Freimann

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=20120813195529.GC19139@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --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).