Re: [PATCH 2/3] pids: Split alloc_pidmap into parts

From: Oleg Nesterov
Date: Thu Nov 10 2011 - 13:17:14 EST


On 11/10, Pavel Emelyanov wrote:
>
> The map's page allocation code is moved to separate function
> to make clone-with-pids patching simpler.

Sorry for the really cosmetic nit, but I simply can't resist...

> +static int alloc_pidmap_page(struct pidmap *map)
> +{
> + void *page = kzalloc(PAGE_SIZE, GFP_KERNEL);
> +
> + /*
> + * Free the page if someone raced with us
> + * installing it:
> + */
> + spin_lock_irq(&pidmap_lock);
> + if (!map->page) {
> + map->page = page;
> + page = NULL;
> + }
> + spin_unlock_irq(&pidmap_lock);
> + kfree(page);
> +
> + return map->page ? 0 : -1;

Again, I won't insist, but "return !map->page" looks more readable.
Even better (imho) would be to return map->page, and change the
single caller to check "if (!alloc_pidnap_page())".

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/