Staging: media: Use !x in place of NULL comparision
authorBhanusree Pola <bhanusreemahesh@gmail.com>
Thu, 21 Mar 2019 09:35:27 +0000 (15:05 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Mar 2019 19:08:07 +0000 (20:08 +0100)
Test for NULL as !x instead of NULL comparisions for
functions that return NULL on failure.
Issue found using coccinelle
Semantic patch used to solve the problem is as follows

// <smpl>
@@
expression x;
statement S;
@@

x = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|
usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\)(...));

-if(x==NULL)
+if(!x)
// </smpl>

Signed-off-by: Bhanusree Pola <bhanusreemahesh@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/zoran/zoran_driver.c

index 04f88f9d6bb42c708d5ee7093c50bf9fbb0e2d1c..0a99e16e5bd5e568fe4fdcc8733eebda280c0d7c 100644 (file)
@@ -332,7 +332,7 @@ static int jpg_fbuffer_alloc(struct zoran_fh *fh)
 
                if (fh->buffers.need_contiguous) {
                        mem = kmalloc(fh->buffers.buffer_size, GFP_KERNEL);
-                       if (mem == NULL) {
+                       if (!mem) {
                                dprintk(1,
                                        KERN_ERR
                                        "%s: %s - kmalloc failed for buffer %d\n",