mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Cliff Wickman <cpw@sgi.com>
Cc: linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v2] x86: UV uv_tlb.c cleanup
Date: Fri, 20 May 2011 15:19:27 +0200	[thread overview]
Message-ID: <20110520131927.GB17699@elte.hu> (raw)
In-Reply-To: <E1QNPH2-0006eo-8E@eag09.americas.sgi.com>


Ok, the whole file looks a lot better now. A few small details:

* Cliff Wickman <cpw@sgi.com> wrote:

> +	vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
> +	uvhub_descs = (struct uvhub_desc *)vp;
> +	memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
> +	uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
> +
> +	if (get_cpu_topology(base_part_pnode, uvhub_descs, uvhub_mask)) {
> +		kfree(uvhub_descs);
> +		kfree(uvhub_mask);
> +		return 1;
> +	}
> +	if (summarize_uvhub_sockets(nuvhubs, uvhub_descs, uvhub_mask)) {
> +		kfree(uvhub_descs);
> +		kfree(uvhub_mask);
> +		return 1;
> +	}
> +
>  	kfree(uvhub_descs);
>  	kfree(uvhub_mask);
> +	init_per_cpu_tunables();
>  	return 0;

Look how the teardown of uvhub_descs and uvhub_mask is repeated 3 times (!).

What we do in the kernel instead are:

	if (func())
		goto fail;

	if (func2())
		goto fail;

	ret = 0;
out:
	kfree(ptr1);
	kfree(ptr2);

	return ret;

fail:
	ret = 1;
	goto out;
}

this makes it more obvious and more readable.

Thanks,

	Ingo

  reply	other threads:[~2011-05-20 13:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 12:57 Cliff Wickman
2011-05-20 13:19 ` Ingo Molnar [this message]
2011-05-20 13:31 ` Ingo Molnar

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=20110520131927.GB17699@elte.hu \
    --to=mingo@elte.hu \
    --cc=cpw@sgi.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®