WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] USB virt 2.6 split driver patch series

To: harry <harry@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] USB virt 2.6 split driver patch series
From: Oleg Goldshmidt <pub@xxxxxxxxxxxxxx>
Date: 21 Nov 2005 17:26:50 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxx>
Delivery-date: Mon, 21 Nov 2005 15:26:32 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1132581661.31295.134.camel@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Speaking for myself only.
References: <1132579104.31295.110.camel@xxxxxxxxxxxxxxxxxxxxx> <20051121134940.GA25045@xxxxxxxxx> <1132581661.31295.134.camel@xxxxxxxxxxxxxxxxxxxxx>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)
harry <harry@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:

> I have read  Documentation/CodingStyle quite carefully and there is no 
> mention of using braces inside functions.  I'm used to using braces to
> define minimal scopes for local variables which makes the code easier to
> read by minimising the number of variables you need to keep track of
> when reading it and by declaring variables closer to where they are used
> so it is easier to verify that they have been correctly initialised.
> 
> Is this really banned?

Not explicitly, but:

1) It increases the number of almost empty lines, which is explicitly
   frowned upon. An opening brace in an empty line by itself is
   allowed in the beginning of a function body, as per K&R style, and
   it is an exception.

2) It deepens block nesting, which is also explicitly frowned upon.

3) CodingStyle explicitly says that the number of local variables in a
   function should be small (over 5-10 and you are in trouble as far
   as both style and design are concerned). This is a corollary to the
   rule that a function should do one thing and one thing only (but do
   it well). If you follow this rule then introducing blocks to limit
   variable scope is never really justified. If you find yourself in a
   situation where you need such blocking then maybe you should think
   of more modularization (at the function level). Disclaimer: I have
   not studied the patches attentively enough to suggest that you need
   this.

Another style comment that I have is that I think that

struct xenidc_channel_struct {
        void (*submit_message)
         (xenidc_channel * channel, xenidc_channel_message * message);

is inferior to

struct xenidc_channel_struct {
        void (*submit_message)(xenidc_channel * channel,
                               xenidc_channel_message * message);

in terms of readability.

-- 
Oleg Goldshmidt | pub@xxxxxxxxxxxxxxxxxxxxx | http://www.goldshmidt.org

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel