public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor@insightbb.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: Michal Piotrowski <michal.k.k.piotrowski@gmail.com>,
	Andrew Morton <akpm@osdl.org>,
	lm-sensors@lm-sensors.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [lm-sensors] [RFC][PATCH] hwmon:fix sparse warnings + error handling
Date: Mon, 21 Aug 2006 20:43:05 -0400	[thread overview]
Message-ID: <200608212043.06256.dtor@insightbb.com> (raw)
In-Reply-To: <20060821100416.4d356328.khali@linux-fr.org>

On Monday 21 August 2006 04:04, Jean Delvare wrote:
> > --- linux-work-clean/drivers/hwmon/w83627hf.c	2006-08-20 22:02:40.000000000 +0200
> > +++ linux-work/drivers/hwmon/w83627hf.c	2006-08-20 22:27:14.000000000 +0200
> > @@ -513,9 +513,21 @@ static DEVICE_ATTR(in0_max, S_IRUGO | S_
> > 
> >  #define device_create_file_in(client, offset) \
> >  do { \
> > -device_create_file(&client->dev, &dev_attr_in##offset##_input); \
> > -device_create_file(&client->dev, &dev_attr_in##offset##_min); \
> > -device_create_file(&client->dev, &dev_attr_in##offset##_max); \
> > +	err = device_create_file(&client->dev, &dev_attr_in##offset##_input); \
> > +	if (err) {\
> > +		hwmon_device_unregister(data->class_dev); \
> > +		return err; \
> > +	} \
> > +	err = device_create_file(&client->dev, &dev_attr_in##offset##_min); \
> > +	if (err) {\
> > +		hwmon_device_unregister(data->class_dev); \
> > +		return err; \
> > +	} \
> > +	err = device_create_file(&client->dev, &dev_attr_in##offset##_max); \
> > +	if (err) {\
> > +		hwmon_device_unregister(data->class_dev); \
> > +		return err; \
> > +	} \
> >  } while (0)
> 
> _Never_ use "return" in a macro. It's way too confusing for whoever will
> read the code later.
>

Also I believe it is good practice to remove created attributes explicitely
instead of relying on sysfs to do the cleanup - I beliee Greg was going to
remove it from sysfs at some point of time... 

-- 
Dmitry

  reply	other threads:[~2006-08-22  0:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-20 20:44 [RFC][PATCH] hwmon:fix sparse warnings + error handling Michal Piotrowski
2006-08-20 21:49 ` [lm-sensors] " jim.cromie
2006-08-20 22:12   ` Michal Piotrowski
2006-08-20 22:28 ` Alan Cox
2006-08-21  2:30 ` [lm-sensors] " Mark M. Hoffman
2006-08-21  9:11   ` Jean Delvare
2006-08-21 16:46     ` Grant Coady
2006-08-21  8:04 ` Jean Delvare
2006-08-22  0:43   ` Dmitry Torokhov [this message]
2006-08-22 11:34     ` Mark M. Hoffman

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=200608212043.06256.dtor@insightbb.com \
    --to=dtor@insightbb.com \
    --cc=akpm@osdl.org \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=michal.k.k.piotrowski@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox