Category: Linux

drivers/serial/m32r_sio.c: correct use of ! and &

Author: Julia Lawall <julia@diku.dk> In commit e6bafba5b4765a5a252f1b8d31cbf6d2459da337 (“wmi: (!x & y) strikes again”), a bug was fixed that involved converting !x & y to !(x & y). The code below shows the same pattern, and thus should perhaps be fixed in the same way. This is not tested and clearly changes the semantics, so it …

Continue reading

drivers/isdn: correct use of ! and &

Author: Julia Lawall <julia@diku.dk> In commit e6bafba5b4765a5a252f1b8d31cbf6d2459da337 (“wmi: (!x & y) strikes again”), a bug was fixed that involved converting !x & y to !(x & y). The code below shows the same pattern, and thus should perhaps be fixed in the same way. This is not tested and clearly changes the semantics, so it …

Continue reading

drivers/char/isicom.c: correct use of ! and &

Author: Julia Lawall <julia@diku.dk> In commit e6bafba5b4765a5a252f1b8d31cbf6d2459da337 (“wmi: (!x & y) strikes again”), a bug was fixed that involved converting !x & y to !(x & y). The code below shows the same pattern, and thus should perhaps be fixed in the same way. This is not tested and clearly changes the semantics, so it …

Continue reading

V4L/DVB (7285): em28xx: Correct use of ! and &

Author: Julia Lawall <julia@diku.dk> In commit e6bafba5b4765a5a252f1b8d31cbf6d2459da337, a bug was fixed that involved converting !x & y to !(x & y). The code below shows the same pattern, and thus should perhaps be fixed in the same way. This is not tested and clearly changes the semantics, so it is only something to consider. The …

Continue reading

arch/sh/drivers/dma/dma-sh.c: Correct use of ! and &

Author: Julia Lawall <julia@diku.dk> In commit e6bafba5b4765a5a252f1b8d31cbf6d2459da337, a bug was fixed that involved converting !x & y to !(x & y). The code below shows the same pattern, and thus should perhaps be fixed in the same way. This is not tested and clearly changes the semantics, so it is only something to consider. The …

Continue reading

net/9p/trans_virtio.c: Use BUG_ON

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(); } | …

Continue reading

net/rxrpc: Use BUG_ON

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(); } | …

Continue reading

fs/udf: 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@ @@ #include @depends on haskernel@ expression n,d; @@ ( – (n + d – 1) / …

Continue reading

[POWERPC] Use FIELD_SIZEOF in arch/ppc

Author: Julia Lawall <julia@diku.dk> Robert P.J. Day proposed to use the macro FIELD_SIZEOF in replace of code that matches its definition. The modification was made using the following semantic patch (http://www.emn.fr/x-info/coccinelle/) // @haskernel@ @@ #include @depends on haskernel@ type t; identifier f; @@ – (sizeof(((t*)0)->f)) + FIELD_SIZEOF(t, f) @depends on haskernel@ type t; identifier f; …

Continue reading

drivers/video: add missing pci_dev_get

Author: Julia Lawall <julia@diku.dk> pci_get_device does a pci_dev_get, so pci_dev_put needs to be called in an error case The problem was fixed using the following semantic patch. (http://www.emn.fr/x-info/coccinelle/) // @exists@ type T1,T2; identifier E; statement S,S1; expression x1,x2,x3; expression test; int ret != 0; @@ struct pci_dev *E; … ( E = \(pci_get_slot\|pci_get_device\|pci_get_bus_and_slot\)(…); if (E …

Continue reading