kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error
  2010-10-18 14:11 [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error code in failure Julia Lawall
@ 2010-10-18 14:11 ` Liam Girdwood
  2010-10-18 23:31 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-10-18 14:11 UTC (permalink / raw)
  To: Julia Lawall
  Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors,
	linux-kernel

On Mon, 2010-10-18 at 16:11 +0200, Julia Lawall wrote:
> In this code, 0 is returned on failure, even though other
> failures return -ENOMEM or other similar values.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @a@
> identifier alloc;
> identifier ret;
> constant C;
> expression x;
> @@
> 
> x = alloc(...);
> if (x = NULL) { <+... \(ret = -C; \| return -C; \) ...+> }
> 
> @@
> identifier f, a.alloc;
> expression ret;
> expression x,e1,e2,e3;
> @@
> 
> ret = 0
> ... when != ret = e1
> *x = alloc(...)
> ... when != ret = e2
> if (x = NULL) { ... when != ret = e3
>   return ret;
> }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
> Another call to platform_get_resource in the same function returns -ENODEV
> on error, so I have used that value.
> 
>  sound/soc/davinci/davinci-mcasp.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
> index c8e97dc..86918ee 100644
> --- a/sound/soc/davinci/davinci-mcasp.c
> +++ b/sound/soc/davinci/davinci-mcasp.c
> @@ -898,6 +898,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
>  	res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
>  	if (!res) {
>  		dev_err(&pdev->dev, "no DMA resource\n");
> +		ret = -ENODEV;
>  		goto err_release_region;
>  	}
>  
> @@ -912,6 +913,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
>  	res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
>  	if (!res) {
>  		dev_err(&pdev->dev, "no DMA resource\n");
> +		ret = -ENODEV;
>  		goto err_release_region;
>  	}
>  
> 
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


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

* [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error code in failure
  2010-10-18 14:11 ` [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error Liam Girdwood
@ 2010-10-18 14:11 Julia Lawall
  2010-10-18 14:11 ` [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error Liam Girdwood
  2010-10-18 23:31 ` Mark Brown
  -1 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2010-10-18 14:11 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: alsa-devel, Takashi Iwai, Mark Brown, kernel-janitors,
	linux-kernel

In this code, 0 is returned on failure, even though other
failures return -ENOMEM or other similar values.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@a@
identifier alloc;
identifier ret;
constant C;
expression x;
@@

x = alloc(...);
if (x = NULL) { <+... \(ret = -C; \| return -C; \) ...+> }

@@
identifier f, a.alloc;
expression ret;
expression x,e1,e2,e3;
@@

ret = 0
... when != ret = e1
*x = alloc(...)
... when != ret = e2
if (x = NULL) { ... when != ret = e3
  return ret;
}
// </smpl>

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

---
Another call to platform_get_resource in the same function returns -ENODEV
on error, so I have used that value.

 sound/soc/davinci/davinci-mcasp.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index c8e97dc..86918ee 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -898,6 +898,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
 	res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
 	if (!res) {
 		dev_err(&pdev->dev, "no DMA resource\n");
+		ret = -ENODEV;
 		goto err_release_region;
 	}
 
@@ -912,6 +913,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
 	res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
 	if (!res) {
 		dev_err(&pdev->dev, "no DMA resource\n");
+		ret = -ENODEV;
 		goto err_release_region;
 	}
 


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

* Re: [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error
  2010-10-18 14:11 [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error code in failure Julia Lawall
  2010-10-18 14:11 ` [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error Liam Girdwood
@ 2010-10-18 23:31 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-10-18 23:31 UTC (permalink / raw)
  To: Julia Lawall
  Cc: alsa-devel, Takashi Iwai, kernel-janitors, linux-kernel,
	Liam Girdwood

On Mon, Oct 18, 2010 at 04:11:13PM +0200, Julia Lawall wrote:
> In this code, 0 is returned on failure, even though other
> failures return -ENOMEM or other similar values.

Applied, thanks.

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

end of thread, other threads:[~2010-10-18 23:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18 14:11 [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error code in failure Julia Lawall
2010-10-18 14:11 ` [PATCH 1/2] sound/soc/davinci/davinci-mcasp.c: Return error Liam Girdwood
2010-10-18 23:31 ` Mark Brown

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).