Staging: media: Use !x in place of NULL comparision
Subsystems (2)
PATCH 1/1 Staging: media: Use !x in place of NULL comparision
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>
--- drivers/staging/media/zoran/zoran_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/zoran/zoran_driver.c +1 -1
@@ -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",
Signature · 1 line
2.17.1
Quoted 14 lines · Bhanusree Pola
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\)(...));
Review
Quoted 2 lines
(quoted diff) +1
-1-if(x==NULL) +if(!x)
This may have been accepted already, in which case don't worry about it, but the semantic patch is not correct. You need to use the S metavariable that you declared. Coccinelle paterns should be complete syntactic units, so an if needs at least a then branch.
julia
Quoted 30 lines
// </smpl>
Signed-off-by Bhanusree Pola <[email protected]>--- drivers/staging/media/zoran/zoran_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/media/zoran/zoran_driver.c +1
-2@@ -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", --2.17.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190321093527.8167-1-bhanusreemahesh%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 19 lines · Julia Lawall
Quoted 14 lines · Bhanusree Pola
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\)(...));
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +1
-1-if(x==NULL) +if(!x)This may have been accepted already, in which case don't worry about it, but the semantic patch is not correct. You need to use the S metavariable that you declared. Coccinelle paterns should be complete syntactic units, so an if needs at least a then branch.
ok. I understand that. I'll take care of it.
Bhanusree
Quoted 40 lines
julia
Quoted 23 lines
// </smpl>
Signed-off-by Bhanusree Pola <[email protected]>--- drivers/staging/media/zoran/zoran_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/media/zoran/zoran_driver.c +1
-2@@ -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", --2.17.1
Quoted 7 lines
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190321093527.8167-1-bhanusreemahesh%40gmail.com.
For more options, visit https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1903220739080.2621%40hadrien.
For more options, visit https://groups.google.com/d/optout.