Re: [PATCH] hpet: factor timer allocate from open

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andrew Morton
Date: Monday, March 22, 2010 - 3:21 pm

On Thu, 18 Mar 2010 21:06:58 -0700 (PDT)
Magnus Lynch <maglyx@gmail.com> wrote:


A stylistic nit:


The above constructs make it harder for people to modify the code
later.  If they want to add a new local, where to put it?  If they want
to add more code, where to put it?  Plus there are risks that people
will accidentally turn the code into c99-style definitions.

One could do

 {
 	struct hpet_dev *devp;
	int r = hpet_alloc_timer(file);

	if (r < 0)
		return r;


but that's not terribly good either: it adds risk that someone will
later add a leak.

Better is the plain old simple approach:


 {
 	struct hpet_dev *devp;
	int r;

	r = hpet_alloc_timer(file);
	if (r < 0)
		return r;


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] hpet: factor timer allocate from open, Magnus Lynch, (Thu Mar 18, 9:06 pm)
Re: [PATCH] hpet: factor timer allocate from open, Andrew Morton, (Mon Mar 22, 3:21 pm)
Re: [PATCH] hpet: factor timer allocate from open, Magnus Lynch, (Mon Mar 22, 7:02 pm)