drivers/staging: delete double assignment

Author: Julia Lawall <julia@diku.dk> Delete successive assignments to the same location. In three of the cases, the two assignments are identical. In the case of the file rt2860/common/cmm_aes.c, the assigned variable i is never used, so both assignments are dropped. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) …

Lire la suite

drivers/isdn: delete double assignment

Author: Julia Lawall <julia@diku.dk> Delete successive assignments to the same location. In the first case, the hscx array has two elements, so change the assignment to initialize the second one. In the second case, the two assignments are simply identical. Furthermore, neither is necessary, because the effect of the assignment is only visible in the …

Lire la suite

drivers/net/typhoon.c: delete double assignment

Author: Julia Lawall <julia@diku.dk> Delete successive assignments to the same location. The current definition does not initialize the respRing structure, which has the same type as the cmdRing structure, so initialize that one instead. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression i; @@ *i …

Lire la suite

drivers/net/sb1000.c: delete double assignment

Author: Julia Lawall <julia@diku.dk> The other code around these duplicated assignments initializes the 0 1 2 and 3 elements of an array, so change the initialization of the rx_session_id array to do the same. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression i; @@ *i …

Lire la suite

i2c-amd8111: Add proper error handling

Author: Julia Lawall <julia@diku.dk> The functions the functions amd_ec_wait_write and amd_ec_wait_read have an unsigned return type, but return a negative constant to indicate an error condition. A sematic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @exists@ identifier f; constant C; @@ unsigned f(…) { } // Fixing amd_ec_wait_write and amd_ec_wait_read leads to …

Lire la suite

drivers/char/agp/parisc-agp.c: eliminate memory leak

Author: Julia Lawall <julia@diku.dk> alloc_pci_dev allocates some memory, so that memory should be freed before leaving the function in an error case. A simplified version of the semantic match that finds this problem is: (http://coccinelle.lip6.fr/) // @r exists@ local idexpression x; expression E; identifier f1; iterator I; @@ x = alloc_pci_dev(…); f1 ) …> * …

Lire la suite

ASoC: davinci-mcasp.c: Return error code in failure

Author: Julia Lawall <julia@diku.dk> In this code, 0 is returned on failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @a@ identifier alloc; identifier ret; constant C; expression x; @@ x = alloc(…); if (x == NULL) …

Lire la suite

drivers/net/ax88796.c: Return error code in failure

Author: Julia Lawall <julia@diku.dk> In this code, 0 is returned on failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @a@ identifier alloc; identifier ret; constant C; expression x; @@ x = alloc(…); if (x == NULL) …

Lire la suite

jffs2: use kmemdup

Author: Julia Lawall <julia@diku.dk> Convert a sequence of kmalloc and memcpy to use kmemdup. The semantic patch that performs this transformation is: (http://coccinelle.lip6.fr/) // @@ expression a,flag,len; expression arg,e1,e2; statement S; @@ a = – \(kmalloc\|kzalloc\)(len,flag) + kmemdup(arg,len,flag) – memcpy(a,arg,len+1); // Signed-off-by: Julia Lawall Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse — fs/jffs2/dir.c | 3 +– …

Lire la suite

fs/ceph/xattr.c: Use kmemdup

Author: Julia Lawall <julia@diku.dk> Convert a sequence of kmalloc and memcpy to use kmemdup. The semantic patch that performs this transformation is: (http://coccinelle.lip6.fr/) // @@ expression a,flag,len; expression arg,e1,e2; statement S; @@ a = – \(kmalloc\|kzalloc\)(len,flag) + kmemdup(arg,len,flag) – memcpy(a,arg,len+1); // Signed-off-by: Julia Lawall Signed-off-by: Sage Weil — fs/ceph/xattr.c | 3 +– 1 file changed, …

Lire la suite