linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/mfd: Adjust NULL test
@ 2008-12-21 18:08 Julia Lawall
  2009-02-06 14:05 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2008-12-21 18:08 UTC (permalink / raw)
  To: sameo, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Since ei is already known to be non-NULL, I assume that what was intended
was to test the result of kzalloc.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression E,E1;
identifier f,fld,fld1;
statement S1,S2;
@@

E->fld = f(...);
... when != E = E1
    when != E->fld1 = E1
if (
-   E
+   E->fld
           == NULL) S1 else S2
// </smpl>

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

---
 drivers/mfd/htc-egpio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c
--- a/drivers/mfd/htc-egpio.c
+++ b/drivers/mfd/htc-egpio.c
@@ -307,7 +307,7 @@ static int __init egpio_probe(struct pla
 
 	ei->nchips = pdata->num_chips;
 	ei->chip = kzalloc(sizeof(struct egpio_chip) * ei->nchips, GFP_KERNEL);
-	if (!ei) {
+	if (!ei->chip) {
 		ret = -ENOMEM;
 		goto fail;
 	}

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

* Re: [PATCH] drivers/mfd: Adjust NULL test
  2008-12-21 18:08 [PATCH] drivers/mfd: Adjust NULL test Julia Lawall
@ 2009-02-06 14:05 ` Samuel Ortiz
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Ortiz @ 2009-02-06 14:05 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-kernel, kernel-janitors

On Sun, Dec 21, 2008 at 07:08:09PM +0100, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Since ei is already known to be non-NULL, I assume that what was intended
> was to test the result of kzalloc.
Makes sense, thanks. Applied to my for-linus branch.

Cheers,
Samuel.

 
> The semantic patch that makes this change is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
> 
> // <smpl>
> @@
> expression E,E1;
> identifier f,fld,fld1;
> statement S1,S2;
> @@
> 
> E->fld = f(...);
> ... when != E = E1
>     when != E->fld1 = E1
> if (
> -   E
> +   E->fld
>            == NULL) S1 else S2
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  drivers/mfd/htc-egpio.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff -u -p a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c
> --- a/drivers/mfd/htc-egpio.c
> +++ b/drivers/mfd/htc-egpio.c
> @@ -307,7 +307,7 @@ static int __init egpio_probe(struct pla
>  
>  	ei->nchips = pdata->num_chips;
>  	ei->chip = kzalloc(sizeof(struct egpio_chip) * ei->nchips, GFP_KERNEL);
> -	if (!ei) {
> +	if (!ei->chip) {
>  		ret = -ENOMEM;
>  		goto fail;
>  	}

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

end of thread, other threads:[~2009-02-06 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-21 18:08 [PATCH] drivers/mfd: Adjust NULL test Julia Lawall
2009-02-06 14:05 ` Samuel Ortiz

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