[PATCH 0/7] fix error return code

2015-12-26 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @ok exists@ identifier f,ret,i; expression e; constant c; @@ // identify a function that returns a negative return value at least once. f(...) { ... when any ( return -c@i; | ret = -c@i; ... when

[PATCH 3/7] omapfb: fix error return code

2015-12-26 Thread Julia Lawall
hen != *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Julia Lawall <julia.law...@lip6.fr> --- drivers/video/fbdev/omap2/omapfb/displays/encoder-tpd12s015.c | 12 +++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/oma

[PATCH 2/4] ASoC: omap-hdmi-audio: add NULL test

2015-12-20 Thread Julia Lawall
Add NULL test on call to devm_kzalloc. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression x; identifier fld; @@ * x = devm_kzalloc(...); ... when != x == NULL x->fld // Signed-off-by: Julia Lawall <julia.law...@lip6.fr> ---

[PATCH 0/4] add NULL test

2015-12-20 Thread Julia Lawall
Add NULL tests on various calls to kzalloc and devm_kzalloc. The semantic match that finds these problems is as follows: (http://coccinelle.lip6.fr/) // @@ expression x,y; identifier fld; @@ ( x = \(vmalloc\|kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|krealloc\| kmemdup\|kstrdup\|

Re: [PATCH v2 11/25] coccinelle: nand: detect and correct drivers embedding an mtd_info object

2015-12-01 Thread Julia Lawall
On Tue, 1 Dec 2015, Boris Brezillon wrote: > Add nand-priv-no-mtd.cocci to detect and correct NAND controller drivers > directly embedding an mtd_info struct in their private struct. > > Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com> > Cc: Julia Lawall

Re: [PATCH 14/27] mtd: nand: use the mtd instance embedded in struct nand_chip

2015-11-17 Thread Julia Lawall
On Tue, 17 Nov 2015, Boris Brezillon wrote: > Hi Julia, > > On Tue, 17 Nov 2015 10:05:03 +0100 (CET) > Julia Lawall <julia.law...@lip6.fr> wrote: > > > > > (This isn't the worst one, but it just happens to be one of the first.) > > > > There

Re: [PATCH 14/27] mtd: nand: use the mtd instance embedded in struct nand_chip

2015-11-17 Thread Julia Lawall
> > (This isn't the worst one, but it just happens to be one of the first.) > > There are many cases where the typical style would be to declare a new > > variable at the top of the function, where you perform the > > macro/function-call to convert from one abstraction to another. Like > > > >

[PATCH] clk: ti: dra7: constify clk_hw_omap_ops structure

2015-11-15 Thread Julia Lawall
The clk_hw_omap_ops structures are never modified, so declare this one as const, like the others. Done with the help of Coccinelle. Signed-off-by: Julia Lawall <julia.law...@lip6.fr> --- drivers/clk/ti/apll.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/

[PATCH 0/3] delete unneeded of_node_put

2015-10-12 Thread Julia Lawall
Device node iterators perform an of_node_put on each iteration, so putting an of_node_put before going around to the next iteration results in a double put. The complete semantic patch that fixes this problem is as follows (http://coccinelle.lip6.fr): // @r exists@ expression e1,e2; local

[PATCH 1/3] video: omapdss: delete unneeded of_node_put

2015-10-12 Thread Julia Lawall
; iterator i; @@ i(..., child, ...) { ... when != of_node_get(child) * of_node_put(child); ... * continue; } // Signed-off-by: Julia Lawall <julia.law...@lip6.fr> --- drivers/video/fbdev/omap2/dss/omapdss-boot-init.c |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff

[PATCH 01/11] mmc: omap: fix error return code

2015-08-22 Thread Julia Lawall
!= ret *if(...) { ... when != ret = e2 when forall return ret; } // /smpl Signed-off-by: Julia Lawall julia.law...@lip6.fr --- drivers/mmc/host/omap.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 70dcf07

[PATCH 00/11] fix error return code

2015-08-22 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @ok exists@ identifier f,ret,i; expression e; constant c; @@ // identify a function that returns a negative return value at least once. f(...) { ... when any ( return -c@i; | ret = -c@i; ...

[PATCH 4/9] sound/soc/omap/am3517evm.c: fix error return code

2015-04-05 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr It was forgotten to initialize ret to the result of calling snd_soc_dai_set_sysclk, unlike at the other calls in the same function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl

Re: [PATCH 4/9] sound/soc/omap/am3517evm.c: fix error return code

2015-04-05 Thread Julia Lawall
Please ignore. Wrong patch set. On Sun, 5 Apr 2015, Julia Lawall wrote: From: Julia Lawall julia.law...@lip6.fr It was forgotten to initialize ret to the result of calling snd_soc_dai_set_sysclk, unlike at the other calls in the same function. A simplified version of the semantic match

Re: [Cocci] [PATCH v13 3/6] clk: Make clk API return per-user struct clk instances

2015-02-06 Thread Julia Lawall
On Fri, 6 Feb 2015, Quentin Lambert wrote: On 06/02/2015 03:15, Stephen Boyd wrote: Thanks for the coccinelle patch. Thinking more about it, I don't think we care if the pointer is dereferenced because that would require a definition of struct clk and that is most likely not the case

Re: [PATCH v13 3/6] clk: Make clk API return per-user struct clk instances

2015-02-02 Thread Julia Lawall
On Mon, 2 Feb 2015, Stephen Boyd wrote: On 02/01/15 13:24, Mike Turquette wrote: Quoting Tomeu Vizoso (2015-01-23 03:03:30) Moves clock state to struct clk_core, but takes care to change as little API as possible. struct clk_hw still has a pointer to a struct clk, which is the

[PATCH 4/9] sound/soc/omap/am3517evm.c: fix error return code

2014-11-23 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr It was forgotten to initialize ret to the result of calling snd_soc_dai_set_sysclk, unlike at the other calls in the same function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl

[PATCH] usb: dwc3: return error code from the most recent call

2014-11-22 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Copy-paste error from the previous block of error handling code. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @@ expression e,e1; @@ if (IS_ERR(e)) { ... ( ret = PTR_ERR(e

[PATCH 0/7] fix error return code

2014-11-20 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @ok exists@ identifier f,ret,i; expression e; constant c; @@ // identify a function that returns a negative return value at least once. f(...) { ... when any ( return -c@i; | ret = -c@i; ...

[PATCH 3/7] dwc3: dwc3-keystone: fix error return code

2014-11-20 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Return a negative error code on failure. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @@ identifier ret; expression e1,e2; @@ ( if (\(ret 0\|ret != 0\)) { ... return ret; } | ret

[PATCH 7/9] OMAPDSS: DSI: use c99 initializers in structures

2014-08-23 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Use c99 initializers for structures. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @decl@ identifier i1,fld; type T; field list[n] fs; @@ struct i1 { fs T fld; ...}; @bad

[PATCH 0/9] use c99 initializers in structures

2014-08-23 Thread Julia Lawall
These patches add labels in the initializations of structure fields (c99 initializers). The complete semantic patch thta makes this change is shown below. This rule ignores cases where the initialization is just 0 or NULL, where some of the fields already use labels, and where there are nested

[PATCH 0/6] simplify platform_get_resource_byname/devm_ioremap_resource

2013-08-19 Thread Julia Lawall
devm_ioremap_resource often uses the result of a call to platform_get_resource_byname as its last argument. devm_ioremap_resource does appropriate error handling on this argument, so error handling can be removed from the call to platform_get_resource_byname. The semantic patch that makes this

[PATCH 1/6] ASoC: omap: simplify platform_get_resource_byname/devm_ioremap_resource

2013-08-19 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Remove unneeded error handling on the result of a call to platform_get_resource_byname when the value is passed to devm_ioremap_resource. In the case of omap-dmic.c, the error-handling code of devm_ioremap_resource is also corrected to include releasing

[PATCH 29/29] usb: dwc3: omap: simplify use of devm_ioremap_resource

2013-08-14 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // smpl

[PATCH 0/29] simplify use of devm_ioremap_resource

2013-08-14 Thread Julia Lawall
devm_ioremap_resource often uses the result of a call to platform_get_resource as its last argument. devm_ioremap_resource does appropriate error handling on this argument, so error handling can be removed from the call site. To make the connection between the call to platform_get_resource and

[PATCH 1/5 v2] drivers/gpio/gpio-omap.c: convert comma to semicolon

2013-08-13 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Replace a comma between expression statements by a semicolon. This changes the semantics of the code, but given the current indentation appears to be what is intended. A simplified version of the semantic patch that performs this transformation

[PATCH 1/5] drivers/gpio/gpio-omap.c: convert comma to semicolon

2013-08-10 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Replace a comma between expression statements by a semicolon. A simplified version of the semantic patch that performs this transformation is as follows: (http://coccinelle.lip6.fr/) // smpl @r@ expression e1,e2,e; type T; identifier i; @@ e1 -, +; e2

[PATCH 13/15] drivers/usb/musb/omap2430.c: adjust duplicate test

2013-01-21 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Delete successive tests to the same location. Data is the just previously allocated and tested value. Test the result of the allocation made here instead. A simplified version of the semantic match that finds this problem is as follows: (http

[PATCH 6/8] arch/arm/mach-omap2/dpll3xxx.c: drop if around WARN_ON

2012-11-03 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Just use WARN_ON rather than an if containing only WARN_ON(1). A simplified version of the semantic patch that makes this transformation is as follows: (http://coccinelle.lip6.fr/) // smpl @@ expression e; @@ - if (e) WARN_ON(1); + WARN_ON(e); // /smpl

[PATCH 4/9] sound/soc/omap/am3517evm.c: fix error return code

2012-08-19 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr It was forgotten to initialize ret to the result of calling snd_soc_dai_set_sysclk, unlike at the other calls in the same function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl

[PATCH] drivers/video/omap2/dss: use devm_ functions

2012-01-24 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr The various devm_ functions allocate memory that is released when a driver detaches. This patch uses these functions for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia

[PATCH] use devm_ functions

2012-01-24 Thread Julia Lawall
The semantic patch (http://coccinelle.lip6.fr/) used in generating this patch is as follows. Some manual cleanup was required. virtual after_start virtual returned virtual arg virtual get virtual drop_labels // - // find

[PATCH 15/15] arch/arm/mach-omap2/smartreflex.c: add missing iounmap

2012-01-12 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Add missing iounmap in error handling code, in a case where the function already preforms iounmap on some other execution path. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl

[PATCH 3/9] drivers/usb/dwc3/dwc3-pci.c: introduce missing kfree

2011-12-23 Thread Julia Lawall
!= if (...) { +...x...+ } x-f1 ... ( return \(0\|+...x...+\|ptr\); | return@p2 ...; ) @script:python@ p1 r.p1; p2 r.p2; @@ print * file: %s kmalloc %s return %s % (p1[0].file,p1[0].line,p2[0].line) // /smpl Signed-off-by: Julia Lawall ju...@diku.dk --- drivers/usb/dwc3/dwc3-pci.c |2 +- 1 file changed

[PATCH 6/9] arch/arm/mach-omap2/devices.c: introduce missing kfree

2011-12-23 Thread Julia Lawall
Signed-off-by: Julia Lawall ju...@diku.dk --- arch/arm/mach-omap2/devices.c |1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index 46dfd1a..3334a47 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c

[PATCH 3/4] drivers/usb/host/ohci-omap3.c: test the just-initialized value

2011-08-22 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk Test the just-initialized value rather than some other one. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @r@ identifier x,y,f!={PTR_ERR,ERR_PTR,ERR_CAST}; statement S; @@ x = f(...); ( if (\(x == NULL\|IS_ERR(x

[PATCH 3/5] arch/arm/mach-omap2/smartreflex.c: add missing error-handling code

2011-07-04 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk At this point, the ioremap has taken place, so the error handling code at the label err_iounmap should be used rather than returning directly. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @r@ identifier x

[PATCH 9/10] arch/arm/mach-omap2/clock.c: add missing clk_put

2011-06-01 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk Add missing call to clk_put. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @r exists@ expression e1,e2; statement S; @@ e1 = clk_get@p1(...); ... when != e1 = e2 when != clk_put(e1

[PATCH] arch/arm/mach-omap1/dma.c: Invert calls to platform_device_put and platform_device_del

2011-05-13 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk Platform_device_del should be called before platform_device_put, as platform_device_put can delete the structure. Additionally, improve the error handling code for the call to ioremap, so that it calls platform_device_put. The semantic match that finds

[PATCH 1/2] arch/arm/mach-omap2/dma.c: Convert IS_ERR result to PTR_ERR

2011-01-27 Thread Julia Lawall
); } // /smpl Signed-off-by: Julia Lawall ju...@diku.dk --- arch/arm/mach-omap2/dma.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff -u -p a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c --- a/arch/arm/mach-omap2/dma.c +++ b/arch/arm/mach-omap2/dma.c @@ -264,7 +264,7

[PATCH 4/4] arch/arm/mach-omap2/smartreflex.c: Add missing IS_ERR test

2011-01-24 Thread Julia Lawall
; @@ x = f(...) ... when != IS_ERR(x) ( if (IS_ERR(x) ||...) S1 else S2 | *x-fld ) // /smpl Signed-off-by: Julia Lawall ju...@diku.dk --- arch/arm/mach-omap2/smartreflex.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach

[PATCH 12/14] drivers/video/omap/blizzard.c: delete double assignment

2010-10-26 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk Delete successive assignments to the same location. Initialize the out_y field as well as the out_x field, rather than initializing the out_x field twice. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6

[PATCH 12/17] drivers/video/omap2/displays: Add missing mutex_unlock

2010-05-26 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk Add a mutex_unlock missing on the error paths. The use of the mutex is balanced elsewhere in the file. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @@ expression E1; @@ * mutex_lock(E1,...); +... when != E1

[PATCH 12/14] arch/arm/plat-omap: Drop an unnecessary NULL test

2009-10-17 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk map_iovm_area is only called from a context where its second argument is known not to be NULL, so drop the unnecessary test. If new could be NULL, the initialization of da should be moved below the test. A simplified version of the semantic match that detects

[PATCH 1/10] arch/arm/plat-omap: Drop unnecessary NULL test

2009-07-19 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk The function map_iovm_area is static and is only called from one place, at which the new argument cannot be NULL. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // smpl @@ type T; expression E,E1; identifier i,fld

[PATCH 9/10] drivers/mmc: Move a dereference below a NULL test

2009-07-19 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk If the NULL test is necessary, then the dereference should be moved below the NULL test. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // smpl @@ type T; expression E,E1; identifier i,fld; statement S; @@ - T i