staging: vpfe_mc_capture: Clean up tests if NULL returned on failure
authorsimran singhal <singhalsimran0@gmail.com>
Fri, 10 Mar 2017 05:13:11 +0000 (10:43 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Mar 2017 13:57:00 +0000 (14:57 +0100)
Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c

index 32109cdd73a66947fca7bc3015d438f9a4e45afe..bffe2153b91081e4f9b70f1d0d53f29380a765f9 100644 (file)
@@ -228,7 +228,7 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev)
 
        vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks,
                                 sizeof(*vpfe_dev->clks), GFP_KERNEL);
-       if (vpfe_dev->clks == NULL)
+       if (!vpfe_dev->clks)
                return -ENOMEM;
 
        for (i = 0; i < vpfe_cfg->num_clocks; i++) {
@@ -348,7 +348,7 @@ static int register_i2c_devices(struct vpfe_device *vpfe_dev)
        vpfe_dev->sd =
                  kcalloc(num_subdevs, sizeof(struct v4l2_subdev *),
                          GFP_KERNEL);
-       if (vpfe_dev->sd == NULL)
+       if (!vpfe_dev->sd)
                return -ENOMEM;
 
        for (i = 0, k = 0; i < num_subdevs; i++) {