]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Staging: cpc-usb: Adjust NULL test
authorJulia Lawall <julia@diku.dk>
Wed, 20 May 2009 07:17:11 +0000 (09:17 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 19 Jun 2009 18:00:53 +0000 (11:00 -0700)
Since card must already be non-NULL, it seems that what was intended
was to test the result of kmalloc.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/cpc-usb/cpc-usb_drv.c

index 14aca399fc4c7a9c7c23cfc34d2987a1ac3c8b41..672f7866a69cfb05477166ef55aed4f9918d1f78 100644 (file)
@@ -899,7 +899,7 @@ static int cpcusb_probe(struct usb_interface *interface,
 
        /* allocate and initialize the channel struct */
        card->chan = kmalloc(sizeof(CPC_CHAN_T), GFP_KERNEL);
-       if (!card) {
+       if (!card->chan) {
                kfree(card);
                err("Out of memory");
                return -ENOMEM;