Category: Linux

ide: 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

drivers/net/appletalk: use time_before, time_before_eq, etc

Author: Julia Lawall <julia@diku.dk> The functions time_before, time_before_eq, time_after, and time_after_eq are more robust for comparing jiffies against other values. A simplified version of the semantic patch making this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @ change_compare_np @ expression E; @@ ( – jiffies = E + time_after_eq(jiffies,E) | – jiffies < E + time_before(jiffies,E) …

Continue reading

drivers/atm: use time_before, time_before_eq, etc

Author: Julia Lawall <julia@diku.dk> The functions time_before, time_before_eq, time_after, and time_after_eq are more robust for comparing jiffies against other values. A simplified version of the semantic patch making this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @ change_compare_np @ expression E; @@ ( – jiffies = E + time_after_eq(jiffies,E) | – jiffies < E + time_before(jiffies,E) …

Continue reading

RDMA/iwcm: Test rdma_create_id() for IS_ERR rather than 0

Author: Julia Lawall <julia@diku.dk> The function rdma_create_id() always returns either a valid pointer or a value made with ERR_PTR, so its result should be tested with IS_ERR, not with a test for 0. The problem was found using the following semantic match. (http://www.emn.fr/x-info/coccinelle/) // @a@ expression E, E1; statement S,S1; position p; @@ E = …

Continue reading

V4L/DVB (7591): drivers/media/video: use time_before, time_before_eq, etc

Author: Julia Lawall <julia@diku.dk> The functions time_before, time_before_eq, time_after, and time_after_eq are more robust for comparing jiffies against other values. A simplified version of the semantic patch making this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @ change_compare_np @ expression E; @@ ( – jiffies = E + time_after_eq(jiffies,E) | – jiffies < E + time_before(jiffies,E) …

Continue reading

[POWERPC] Use FIELD_SIZEOF in drivers/block/viodasd.c

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

ACPI: drivers/acpi: elide a non-zero test on a result that is never 0

Author: Julia Lawall <julia@diku.dk> The function thermal_cooling_device_register always returns either a valid pointer or a value made with ERR_PTR, so a test for non-zero on the result will always succeed. The problem was found using the following semantic match. (http://www.emn.fr/x-info/coccinelle/) // @a@ expression E, E1; statement S,S1; position p; @@ E = thermal_cooling_device_register(…) … when …

Continue reading

[GFS2] test for IS_ERR rather than 0

Author: Julia Lawall <julia@diku.dk> The function gfs2_inode_lookup always returns either a valid pointer or a value made with ERR_PTR, so its result should be tested with IS_ERR, not with a test for 0. The problem was found using the following semantic match. (http://www.emn.fr/x-info/coccinelle/) // @a@ expression E, E1; statement S,S1; position p; @@ E = …

Continue reading

[9P] net/9p/trans_fd.c: remove unused variable

Author: Julia Lawall <julia@diku.dk> The variable cb is initialized but never used otherwise. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ type T; identifier i; constant C; @@ ( extern T i; | – T i; ) // Signed-off-by: Julia Lawall Signed-off-by: David S. Miller — net/9p/trans_fd.c | 2 — …

Continue reading

[IPV6] net/ipv6/ndisc.c: remove unused variable

Author: Julia Lawall <julia@diku.dk> The variable hlen is initialized but never used otherwise. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ type T; identifier i; constant C; @@ ( extern T i; | – T i; ) // Signed-off-by: Julia Lawall Signed-off-by: David S. Miller — net/ipv6/ndisc.c | 2 — …

Continue reading