Category: Coccinelle

drivers/rtc: correct error-handling code

Author: Julia Lawall <julia@diku.dk> This code is not executed before ds1307->rtc has been successfully initialized to the result of calling rtc_device_register. Thus the test that ds1307->rtc is not NULL is always true. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @match exists@ expression x, E; statement S1, …

Continue reading

drivers/net/wireless: Use usb_endpoint_dir_out

Author: Julia Lawall <julia@diku.dk> Use the usb_endpoint_dir_out API function. Note that the use of USB_TYPE_MASK in the original code is incorrect; it results in a test that is always false. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ struct usb_endpoint_descriptor *endpoint; expression E; @@ – (endpoint->bEndpointAddress & E) == USB_DIR_OUT …

Continue reading

MIPS: SMTC: Remove duplicate structure field initialization

Author: Julia Lawall <julia@diku.dk> The definition of the irq_ipi structure has two initializations of the flags field. This combines them. [Ralf: The issue was originally introduced by commit be4894196d79455f420dd7bb78be7dc73bec115c (linux-mips.org) rsp. 033890b084adfa367c544864451d7730552ce8bf (kernel.org). The original intention of the code was to initialize .flags with both flags ored together. The broken C code as actually implemented …

Continue reading

Staging: slicoss: remove duplicate structure field initialization

Author: Julia Lawall <julia@diku.dk> The definition of slic_netdev_ops has initializations of a local function and eth_mac_addr for its ndo_set_mac_address field. This change uses only the local function. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier I, s, fld; position p0,p; expression E; @@ struct I s =@p0 { … …

Continue reading

V4L/DVB (13166): remove duplicate structure field initialization

Author: Julia Lawall <julia@diku.dk> The definition of tvaudio_tuner_ops initializes the s_tuner field twice. It appears that the second case should initialize the g_tuner field. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier I, s, fld; position p0,p; expression E; @@ struct I s =@p0 { … .fld@p = E, …

Continue reading

drivers/net: remove duplicate structure field initialization

Author: Julia Lawall <julia@diku.dk> The definitions of vnet_ops and ehea_netdev_ops have initializations of a local function and eth_change_mtu for their respective ndo_change_mtu fields. This change uses only the local function. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier I, s, fld; position p0,p; expression E; @@ struct I s …

Continue reading

USB: skeleton: Correct use of ! and &

Author: Julia Lawall <julia@diku.dk> Correct priority problem in the use of ! and &. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression E; constant C; @@ – !E & C + !(E & C) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman — drivers/usb/usb-skeleton.c | 4 ++– 1 file changed, …

Continue reading

i2c-pnx: Correct use of request_region/request_mem_region

Author: Julia Lawall <julia@diku.dk> request_mem_region should be used when ioremap is used subsequently. release_region is then correspondingly replaced by release_mem_region. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ expression start,E; @@ – request_region + request_mem_region (start,…) … when != request_mem_region(start,…) when != start = E ioremap(start,…) @@ expression r.start; @@ …

Continue reading

V4L/DVB (13012): uvc: introduce missing kfree

Author: Julia Lawall <julia@diku.dk> Move the kzalloc and associated test after the stream/query test, to avoid the need to free the allocated if the stream/query test fails. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != …

Continue reading

hwmon: Use resource_size

Author: Julia Lawall <julia@diku.dk> Use the function resource_size, which reduces the chance of introducing off-by-one errors in calculating the resource size. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ struct resource *res; @@ – (res->end – res->start) + 1 + resource_size(res) // Signed-off-by: Julia Lawall Signed-off-by: Jean Delvare — drivers/hwmon/pc87427.c …

Continue reading