media: staging: atomisp2: cleanup null check on memory allocation
authorAishwarya Pant <aishpant@gmail.com>
Tue, 17 Oct 2017 13:14:09 +0000 (15:14 +0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 27 Oct 2017 15:33:39 +0000 (17:33 +0200)
commitbbae615636155fa43a9b0fe0ea31c678984be864
treeaadaef5afb9470e55d21f1762e995e64eca306a8
parent1f709713cbd70efe85e76d9e9453606c6cc4bf82
media: staging: atomisp2: cleanup null check on memory allocation

For memory allocation functions that fail with a NULL return value, it
is preferred to use the (!x) test in place of (x == NULL).

Changes in atomisp2/css2400/sh_css.c were done by hand.

Done with the help of the following cocci script:

@@
type T;
T* p;
statement s,s1;
@@

p =
  \(devm_kzalloc\|devm_ioremap\|usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\|
   kmalloc\|kmalloc_array\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
   kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|devm_kzalloc\)(...)
...when != p

if (
- p == NULL
+ !p
 ) s
 else s1

--
Changes in v3:
  Rebase changes over atomisp-next branch of the media tree
Changes in atomisp2/css2400/sh_css.c were done by hand, the above script
was not able to match the pattern if (a->b != null).

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_param_shading.c