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] [PATCH][2/17] USB virt 2.6 split driver---xenidc buffer

To: harry <harry@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH][2/17] USB virt 2.6 split driver---xenidc buffer resource provider
From: Muli Ben-Yehuda <mulix@xxxxxxxxx>
Date: Mon, 21 Nov 2005 22:18:11 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 21 Nov 2005 20:18:22 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1132579125.31295.113.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>
References: <1132579125.31295.113.camel@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.11
> +static int xenidc_buffer_resource_provider_init_or_exit
> +    (xenidc_buffer_resource_provider * provider, int exit) {
> +     trace1("%p", provider);
> +
> +     {

This function is way way too long.

> +             {

No internal blocks please.

> +             if (provider->resource_allocation.empty_page_ranges != 0) {
> +                     provider->page = balloon_alloc_empty_page_range
> +                         (provider->resource_allocation.empty_page_ranges
> +                          *
> +                          provider->resource_allocation.
> +                          empty_page_range_page_count);

lindent brain damage (putting the '*' on its own line).

> +                     if (provider->page == NULL) {
> +                             return_value = -ENOMEM;
> +
> +                             goto EXIT_NO_EMPTY_PAGE_RANGE;

common style is not to put the label in all uppercaps.

> +                     if (xenidc_buffer_resource_provider_init_or_exit
> +                         (provider, 0)
> +                         != 0) {
> +                             vfree(provider);

using vmalloc/vfree is discouraged unless you must.

> +void xenidc_free_buffer_resource_provider
> +    (xenidc_buffer_resource_provider * provider) {
> +     trace();
> +
> +     (void)xenidc_buffer_resource_provider_init_or_exit(provider, 1);
> +
> +     vfree(provider);

If init_or_exit fails won't you vfree an already freed pointer here?

> +             xenidc_buffer_resource_list list;
> +
> +             unsigned long flags;
> +
> +             spin_lock_irqsave(&provider->lock, flags);
> +
> +             list = provider->free_resources;
> +
> +             spin_unlock_irqrestore(&provider->lock, flags);
> +
> +             return list;

You have a lot of empty lines. This function needs no empty lines, for
example, except maybe after the variable declarations. Also, does
'list' need to be reference counted here?

> +typedef struct xenidc_buffer_resource_provider_struct
> +    xenidc_buffer_resource_provider;

don't typedef structs.

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/


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