From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T10ia-0007ck-Fb for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:54:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T10iZ-0005VC-Iy for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:54:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T10iZ-0005V7-BB for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:54:27 -0400 Date: Mon, 13 Aug 2012 22:55:29 +0300 From: "Michael S. Tsirkin" Message-ID: <20120813195529.GC19139@redhat.com> References: <1344883606-14854-1-git-send-email-aliguori@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1344883606-14854-1-git-send-email-aliguori@us.ibm.com> Subject: Re: [Qemu-devel] [PATCH] qom: add style guide List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Andreas Faerber 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