Catégorie : Coccinelle

drivers/usb/class/usblp.c: adjust error handling code

Author: Julia Lawall <julia@diku.dk> In this code, it is possible to tell statically whether usblp will be NULL in the error handling code. Oliver Neukum suggested to make a goto to the final return rather than return directly. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ identifier f,err,l,l1; type T; …

Lire la suite

net/ieee80211: adjust error handling

Author: Julia Lawall <julia@diku.dk> Converts a test in error handling code to a sequence of labels. The semantic match that found the problem is: (http://www.emn.fr/x-info/coccinelle/) // @@ expression E,E1,E2; @@ E = alloc_etherdev(…) … when != E = E1 if (…) { … free_netdev(E); … return …; } … when != E = E2 ( …

Lire la suite

[S390] drivers/s390: Eliminate NULL test and memset after alloc_bootmem

Author: Julia Lawall <julia@diku.dk> As noted by Akinobu Mita in patch b1fceac2b9e04d278316b2faddf276015fc06e3b, alloc_bootmem and related functions never return NULL and always return a zeroed region of memory. Thus a NULL test or memset after calls to these functions is unnecessary. drivers/s390/char/raw3270.c | 11 +———- drivers/s390/char/sclp_con.c | 2 — 2 files changed, 1 insertion(+), 12 deletions(-) …

Lire la suite

[S390] arch/s390: Eliminate NULL test and memset after alloc_bootmem

Author: Julia Lawall <julia@diku.dk> As noted by Akinobu Mita in patch b1fceac2b9e04d278316b2faddf276015fc06e3b, alloc_bootmem and related functions never return NULL and always return a zeroed region of memory. Thus a NULL test or memset after calls to these functions is unnecessary. arch/s390/kernel/topology.c | 2 — 1 file changed, 2 deletions(-) This was fixed using the following …

Lire la suite

ext4: Use BUG_ON() instead of BUG()

Author: Julia Lawall <julia@diku.dk> if (…) BUG(); should be replaced with BUG_ON(…) when the test has no side-effects to allow a definition of BUG_ON that drops the code completely. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @ disable unlikely @ expression E,f; @@ ( if () { BUG(); } | …

Lire la suite

It looks at least odd to apply spin_unlock to a mutex.

Author: Julia Lawall <julia@diku.dk> The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @def@ declarer DEFINE_MUTEX; identifier m; @@ DEFINE_MUTEX(m); @@ identifier def.m; @@ ( – spin_lock(&m) + mutex_lock(&m) | – spin_unlock(&m) + mutex_unlock(&m) ) // Signed-off-by: Julia Lawall Signed-off-by: Jesper Nilsson — arch/cris/arch-v10/drivers/pcf8563.c | 2 +- arch/cris/arch-v32/drivers/pcf8563.c | 2 +- 2 …

Lire la suite

drivers/net/r6040.c: Eliminate double sizeof

Author: Julia Lawall <julia@diku.dk> Taking sizeof the result of sizeof is quite strange and does not seem to be what is wanted here. This was fixed using the following semantic patch. (http://www.emn.fr/x-info/coccinelle/) // @@ expression E; @@ – sizeof ( sizeof (E) – ) // Signed-off-by: Julia Lawall Signed-off-by: Jeff Garzik — drivers/net/r6040.c | 2 …

Lire la suite

drivers/isdn/sc/ioctl.c: add missing kfree

Author: Julia Lawall <julia@diku.dk> spid has been allocated in this function and so should be freed before leaving it, as in the other error handling cases. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) @r exists@ expression E,E1; statement S; position p1,p2,p3; @@ E =@p1 \(kmalloc\|kcalloc\|kzalloc\)(…) … when != E = E1 …

Lire la suite

[S390] tape_3590.c: introduce missing kfree

Author: Julia Lawall <julia@diku.dk> The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) @r exists@ expression E,E1; statement S; position p1,p2,p3; @@ E =@p1 \(kmalloc\|kcalloc\|kzalloc\)(…) … when != E = E1 if (E == NULL || …) S … when != E = E1 if@p2 (…) { … when != kfree(E) } … …

Lire la suite

[POWERPC] Add missing of_node_put in drivers/macintosh/therm_adt746x.c

Author: Julia Lawall <julia@diku.dk> of_node_put is needed before discarding a value received from of_find_node_by_name, eg in error handling code. The semantic patch that makes the change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ struct device_node *n; struct device_node *n1; statement S; identifier f; expression E; constant C; @@ n = of_find_node_by_name(…) … if (!n) S … …

Lire la suite