From: Harry Butterworth <harry@hebutterworth.freeserve.co.uk>
To: Muli Ben-Yehuda <mulix@mulix.org>
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH][2/17] USB virt 2.6 split driver---xenidc buffer resource provider
Date: Mon, 21 Nov 2005 21:30:00 +0000 [thread overview]
Message-ID: <1132608600.4739.24.camel@localhost> (raw)
In-Reply-To: <20051121201811.GB22728@granada.merseine.nu>
On Mon, 2005-11-21 at 22:18 +0200, Muli Ben-Yehuda wrote:
> > +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.
It's straight line code doing initialisation. Breaking it up would be
artificial. I suppose I could split it up to have a separate init
function for each kind of resource.
>
> > + {
>
> No internal blocks please.
Well, I agree that they don't work well with 8 space tabs. So, while we
have the big tabs I guess they'll have to go.
>
> > + 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).
OK.
>
> > + if (provider->page == NULL) {
> > + return_value = -ENOMEM;
> > +
> > + goto EXIT_NO_EMPTY_PAGE_RANGE;
>
> common style is not to put the label in all uppercaps.
>
OK.
> > + if (xenidc_buffer_resource_provider_init_or_exit
> > + (provider, 0)
> > + != 0) {
> > + vfree(provider);
>
> using vmalloc/vfree is discouraged unless you must.
I don't understand this. I thought vmalloc was more likely to be
successful than kmalloc because the memory doesn't need to be contiguous
so I thought it was preferable to use vmalloc when possible.
>
> > +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?
No, init_or_exit never fails on the exit path so the code is correct.
>
> > + 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?
I'm used to a lot of empty lines. I can get rid of them all if you
like.
No, 'list' doesn't need to be reference counted.
>
> > +typedef struct xenidc_buffer_resource_provider_struct
> > + xenidc_buffer_resource_provider;
>
> don't typedef structs.
OK.
>
> Cheers,
> Muli
--
Harry Butterworth <harry@hebutterworth.freeserve.co.uk>
next prev parent reply other threads:[~2005-11-21 21:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-21 13:18 [PATCH][2/17] USB virt 2.6 split driver---xenidc buffer resource provider harry
2005-11-21 20:18 ` Muli Ben-Yehuda
2005-11-21 21:30 ` Harry Butterworth [this message]
2005-11-22 10:55 ` Muli Ben-Yehuda
2005-11-22 11:11 ` harry
2005-11-22 11:12 ` Keir Fraser
2005-11-22 11:22 ` Muli Ben-Yehuda
2005-11-22 12:06 ` Keir Fraser
2005-11-22 12:14 ` *** SPAM *** " harry
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=1132608600.4739.24.camel@localhost \
--to=harry@hebutterworth.freeserve.co.uk \
--cc=mulix@mulix.org \
--cc=xen-devel@lists.xensource.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.