staging: unisys: visorchannel: Improved cleanup code
authorTapasweni Pathak <tapaswenipathak@gmail.com>
Sat, 25 Oct 2014 05:16:02 +0000 (10:46 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Oct 2014 07:41:43 +0000 (15:41 +0800)
commitbe40a5e29e3eba9c5628512b6f991ab6822a3f04
tree0d458b358dd900453ff2eccc0f58a4b62f98d8b3
parenta707edd2360e739a27fd7b1720edd075ee5f7f64
staging: unisys: visorchannel: Improved cleanup code

kfree on NULL pointer is a no-op.

This patch used the following semantic patch to find an instance where NULL
check is present before kfree

// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);
@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Code is made more simpler by breaking up of sequence of kmallocs and adding
some more exit labels.
Removed unnecessary initialization of buf and fmtbuf to NULL as they are local
variables.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorchannel/visorchannel_funcs.c
This page took 0.024783 seconds and 5 git commands to generate.