Category: Linux

GFS2: Use an IS_ERR test rather than a NULL test

Author: Julien Brunel <brunel@diku.dk> In case of error, the function gfs2_inode_lookup returns an ERR pointer, but never returns a NULL pointer. So a NULL test that necessarily comes after an IS_ERR test should be deleted, and a NULL test that may come after a call to this function should be strengthened by an IS_ERR test. …

Continue reading

UBIFS: use an IS_ERR test rather than a NULL test

Author: Julien Brunel <brunel@diku.dk> In case of error, the function kthread_create returns an ERR pointer, but never returns a NULL pointer. So a NULL test that comes before an IS_ERR test should be deleted. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @match_bad_null_test@ expression x, E; statement S1,S2; @@ x = …

Continue reading

Blackfin arch: sram: use ‘unsigned long’ for irqflags

Author: Vegard Nossum <vegard.nossum@gmail.com> Using just ‘unsigned’ will make flags an unsigned int. While this is arguably not an error on blackfin where sizeof(int) == sizeof(long), the patch is still justified on the grounds of principle. The patch was generated using the Coccinelle semantic patch framework. Cc: Julia Lawall Cc: Alexey Dobriyan Signed-off-by: Vegard Nossum …

Continue reading

net/mac80211/mesh.c: correct the argument to __mesh_table_free

Author: Julia Lawall <julia@diku.dk> In the function mesh_table_grow, it is the new table not the argument table that should be freed if the function fails (cf commit bd9b448f4c0a514559bdae4ca18ca3e8cd999c6d) The semantic match that detects this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; expression E,f; position p1,p2,p3; identifier l; statement S; @@ x …

Continue reading

[S390] drivers/s390: Use an IS_ERR test rather than a NULL test

Author: Julien Brunel <brunel@diku.dk> In case of error, functions dasd_kmalloc_request and idal_buffer_alloc return an ERR pointer, but never return the NULL pointer. So after a call to one of these functions, a NULL test should be replaced by an IS_ERR test. A simplified version of the semantic patch that makes this change is as follows: …

Continue reading

V4L/DVB (8729): Use DIV_ROUND_UP

Author: Julia Lawall <julia@diku.dk> The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) – 1) / (d)) but is perhaps more readable. An extract of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @haskernel@ @@ @depends on haskernel@ expression n,d; @@ ( – (n + d – 1) / d …

Continue reading

net/rxrpc: Use an IS_ERR test rather than a NULL test

Author: Julien Brunel <brunel@diku.dk> In case of error, the function rxrpc_get_transport returns an ERR pointer, but never returns a NULL pointer. So after a call to this function, a NULL test should be replaced by an IS_ERR test. A simplified version of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @correct_null_test@ …

Continue reading

IB/mad: Test ib_create_send_mad() return with IS_ERR(), not == NULL

Author: Julien Brunel <brunel@diku.dk> In case of error, the function ib_create_send_mad() returns an ERR pointer, but never returns a NULL pointer. So testing the return value for error should be done with IS_ERR, not by comparing with NULL. A simplified version of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @correct_null_test@ …

Continue reading

au1000_eth: use ‘unsigned long’ for irqflags

Author: Vegard Nossum <vegard.nossum@gmail.com> The patch was generated using the Coccinelle semantic patch framework. Cc: Julia Lawall Cc: Alexey Dobriyan Cc: Jeff Garzik Signed-off-by: Vegard Nossum Signed-off-by: Jeff Garzik — drivers/net/au1000_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)   diff –git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index cb8be49..5ee1b05 100644 — a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c @@ -807,7 …

Continue reading

drivers/video/fsl-diu-fb.c: add missing of_node_put

Author: Julia Lawall <julia@diku.dk> of_node_put is needed before discarding a value received from of_find_node_by_type, 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; struct device_node *n2; statement S; identifier f1,f2; expression E1,E2; constant C; @@ n = of_find_node_by_type(…) … if …

Continue reading