Author: Julia Lawall <julia@diku.dk> Memset should be given the size of the structure, not the size of the pointer. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ type T; T *x; expression E; @@ memset(x, E, sizeof( + * x)) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman — drivers/staging/wlan-ng/prism2fw.c | …
Dec 09 2009
USB: gadget: Use ERR_PTR/IS_ERR
Author: Julia Lawall <julia@diku.dk> Use ERR_PTR and IS_ERR rather than mixing integers and pointers. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression *E; @@ * E < 0 // Signed-off-by: Julia Lawall Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/f_audio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 …
Dec 07 2009
sh: Replace an explicit computation by the use of the container_of macro
Author: Nicolas Palix <npalix@diku.dk> The macro container_of from kernel.h performs the same pointer arithmetic operation. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ type T; expression mptr; expression member; @@ – (void *)((char *)mptr – offsetof(T, member)) + container_of(mptr, T, member) // Signed-off-by: Nicolas Palix Signed-off-by: Paul Mundt — arch/sh/kernel/cpu/irq/ipr.c …
Dec 06 2009
security/selinux/ss: correct size computation
Author: Julia Lawall <julia@diku.dk> The size argument to kcalloc should be the size of desired structure, not the pointer to it. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression *x; @@ x = // Signed-off-by: Julia Lawall Acked-by: Eric Paris Signed-off-by: James Morris — security/selinux/ss/services.c | 4 ++– 1 …
Dec 06 2009
perf tools: Correct size computation in tracepoint_id_to_path()
Author: Julia Lawall <julia@diku.dk> The size argument to zalloc should be the size of desired structure, not the pointer to it. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression *x; @@ x = // Signed-off-by: Julia Lawall Cc: Peter Zijlstra Cc: Mike Galbraith Cc: Paul Mackerras Cc: Arnaldo Carvalho …
Nov 30 2009
arch/alpha/kernel: Add kmalloc NULL tests
Author: Julia Lawall <julia@diku.dk> Check that the result of kmalloc is not NULL before passing it to other functions. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ expression *x; identifier f; constant char *C; @@ x = \(kmalloc\|kcalloc\|kzalloc\)(…); … when != x == NULL when != x != NULL when …
Nov 30 2009
arch/alpha/kernel/sys_ruffian.c: Use DIV_ROUND_CLOSEST
Author: Julia Lawall <julia@diku.dk> The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d but is perhaps more readable. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @haskernel@ @@ @depends on haskernel@ expression x,__divisor; @@ – (((x) + ((__divisor) / 2)) / (__divisor)) + DIV_ROUND_CLOSEST(x,__divisor) // Signed-off-by: Julia Lawall Cc: Ivan …
Nov 22 2009
arch/arm/plat-omap: Drop an unnecessary NULL test
Author: Julia Lawall <julia@diku.dk> map_iovm_area is only called from a context where its second argument is known not to be NULL, so drop the unnecessary test. If new could be NULL, the initialization of da should be moved below the test. A simplified version of the semantic match that detects this problem is as follows …
Nov 22 2009
perf_event: Remove redundant zero fill
Author: Márton Németh <nm127@freemail.hu> The buffer is first zeroed out by memset(). Then strncpy() is used to fill the content. The strncpy() function also pads the string till the end of the specified length, which is redundant. The strncpy() does not ensures that the string will be properly closed with 0. Use strlcpy() instead. The …
Nov 21 2009
drivers/regulator: use PTR_ERR to get error code
Author: Julia Lawall <julia@diku.dk> IS_ERR returns only 1 or 0. The callsite of setup_regulators expects a negative integer in an error case. Thus, PTR_ERR has to be used to extract it. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression E,E1; @@ *E = IS_ERR(…) … when != E = …