linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/42] drivers/hwmon: Adjust confusing if indentation
@ 2010-08-05 20:17 Julia Lawall
  2010-08-06  9:04 ` [lm-sensors] " Charles Logan
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2010-08-05 20:17 UTC (permalink / raw)
  To: Rudolf Marek, lm-sensors, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Move the if(err) statement after the if into the if branch indicated by its
indentation.  The preceding if(err) test implies that err cannot be nonzero
unless the if branch is taken.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable braces4@
position p1,p2;
statement S1,S2;
@@

(
if (...) { ... }
|
if (...) S1@p1 S2@p2
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

if (p1[0].column == p2[0].column):
  cocci.print_main("branch",p1)
  cocci.print_secs("after",p2)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/hwmon/k8temp.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 8bdf80d..b9bb3e0 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -252,12 +252,13 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 				   &sensor_dev_attr_temp3_input.dev_attr);
 		if (err)
 			goto exit_remove;
-		if (data->sensorsp & SEL_PLACE)
+		if (data->sensorsp & SEL_PLACE) {
 			err = device_create_file(&pdev->dev,
 					   &sensor_dev_attr_temp4_input.
 					   dev_attr);
 			if (err)
 				goto exit_remove;
+		}
 	}
 
 	err = device_create_file(&pdev->dev, &dev_attr_name);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH 3/42] drivers/hwmon: Adjust confusing if  indentation
  2010-08-05 20:17 [PATCH 3/42] drivers/hwmon: Adjust confusing if indentation Julia Lawall
@ 2010-08-06  9:04 ` Charles Logan
  2010-08-14 17:44   ` Jean Delvare
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Logan @ 2010-08-06  9:04 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Rudolf Marek, lm-sensors, linux-kernel, kernel-janitors

Corrected:

> // <smpl>
> @r disable braces5@
> position p1,p2;
> statement S1,S2;
> @@
>
> (
> if (...) { ... }
> |
> if (...) S1@p1 S2@p2
> )
>
> @script:python@
> p1 << r.p1;
> p2 << r.p2;
> @@
>
> if (p1[0].column == p2[0].column):
>  cocci.print_main("branch",p4)
>  cocci.print_secs("after",p5)
> // </smpl>



On Thu, Aug 5, 2010 at 10:17 PM, Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Move the if(err) statement after the if into the if branch indicated by its
> indentation.  The preceding if(err) test implies that err cannot be nonzero
> unless the if branch is taken.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @r disable braces4@
> position p1,p2;
> statement S1,S2;
> @@
>
> (
> if (...) { ... }
> |
> if (...) S1@p1 S2@p2
> )
>
> @script:python@
> p1 << r.p1;
> p2 << r.p2;
> @@
>
> if (p1[0].column == p2[0].column):
>  cocci.print_main("branch",p1)
>  cocci.print_secs("after",p2)
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
>  drivers/hwmon/k8temp.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
> index 8bdf80d..b9bb3e0 100644
> --- a/drivers/hwmon/k8temp.c
> +++ b/drivers/hwmon/k8temp.c
> @@ -252,12 +252,13 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
>                                   &sensor_dev_attr_temp3_input.dev_attr);
>                if (err)
>                        goto exit_remove;
> -               if (data->sensorsp & SEL_PLACE)
> +               if (data->sensorsp & SEL_PLACE) {
>                        err = device_create_file(&pdev->dev,
>                                           &sensor_dev_attr_temp4_input.
>                                           dev_attr);
>                        if (err)
>                                goto exit_remove;
> +               }
>        }
>
>        err = device_create_file(&pdev->dev, &dev_attr_name);
>
> _______________________________________________
> lm-sensors mailing list
> lm-sensors@lm-sensors.org
> http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH 3/42] drivers/hwmon: Adjust confusing if  indentation
  2010-08-06  9:04 ` [lm-sensors] " Charles Logan
@ 2010-08-14 17:44   ` Jean Delvare
  0 siblings, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2010-08-14 17:44 UTC (permalink / raw)
  To: Charles Logan; +Cc: Julia Lawall, kernel-janitors, linux-kernel, lm-sensors

Hi Julia, Charles,

On Fri, 6 Aug 2010 11:04:20 +0200, Charles Logan wrote:
> Corrected:
> 
> > // <smpl>
> > @r disable braces5@
> > position p1,p2;
> > statement S1,S2;
> > @@
> >
> > (
> > if (...) { ... }
> > |
> > if (...) S1@p1 S2@p2
> > )
> >
> > @script:python@
> > p1 << r.p1;
> > p2 << r.p2;
> > @@
> >
> > if (p1[0].column == p2[0].column):
> >  cocci.print_main("branch",p4)
> >  cocci.print_secs("after",p5)
> > // </smpl>
> 
> 
> 
> On Thu, Aug 5, 2010 at 10:17 PM, Julia Lawall <julia@diku.dk> wrote:
> > From: Julia Lawall <julia@diku.dk>
> >
> > Move the if(err) statement after the if into the if branch indicated by its
> > indentation.  The preceding if(err) test implies that err cannot be nonzero
> > unless the if branch is taken.
> >
> > The semantic match that finds this problem is as follows:
> > (http://coccinelle.lip6.fr/)
> >
> > // <smpl>
> > @r disable braces4@
> > position p1,p2;
> > statement S1,S2;
> > @@
> >
> > (
> > if (...) { ... }
> > |
> > if (...) S1@p1 S2@p2
> > )
> >
> > @script:python@
> > p1 << r.p1;
> > p2 << r.p2;
> > @@
> >
> > if (p1[0].column == p2[0].column):
> >  cocci.print_main("branch",p1)
> >  cocci.print_secs("after",p2)
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <julia@diku.dk>
> >
> > ---
> >  drivers/hwmon/k8temp.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
> > index 8bdf80d..b9bb3e0 100644
> > --- a/drivers/hwmon/k8temp.c
> > +++ b/drivers/hwmon/k8temp.c
> > @@ -252,12 +252,13 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
> >                                   &sensor_dev_attr_temp3_input.dev_attr);
> >                if (err)
> >                        goto exit_remove;
> > -               if (data->sensorsp & SEL_PLACE)
> > +               if (data->sensorsp & SEL_PLACE) {
> >                        err = device_create_file(&pdev->dev,
> >                                           &sensor_dev_attr_temp4_input.
> >                                           dev_attr);
> >                        if (err)
> >                                goto exit_remove;
> > +               }
> >        }
> >
> >        err = device_create_file(&pdev->dev, &dev_attr_name);
> >

Applied, thanks. Fortunately the bug is harmless, as noted in the patch
comment.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-14 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-05 20:17 [PATCH 3/42] drivers/hwmon: Adjust confusing if indentation Julia Lawall
2010-08-06  9:04 ` [lm-sensors] " Charles Logan
2010-08-14 17:44   ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).