Staging: erofs: Use !x in place of NULL comparision
PATCH 1/1 Staging: erofs: Use !x in place of NULL comparision
Test for NULL as !x instead of NULL comparisions for functions that return NULL on failure are used. 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/erofs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/erofs/xattr.c +1 -1
@@ -107,7 +107,7 @@ static int init_inode_xattrs(struct inode *inode) vi->xattr_shared_count = ih->h_shared_count; vi->xattr_shared_xattrs =kmalloc_array (vi->xattr_shared_count,sizeof (uint),GFP_KERNEL ); -if (vi->xattr_shared_xattrs ==NULL ) { +if (!vi->xattr_shared_xattrs) {xattr_iter_end (&it, atomic_map); ret = -ENOMEM ; goto out_unlock;
Signature · 1 line
2.17.1
PATCH 1/1 Staging: erofs: Use !x in place of NULL comparision
Hi Bhanusree,
Quoted 5 lines · Bhanusree Pola
Test for NULL as !x instead of NULL comparisions for functions that return NULL on failure are used. Issue found using coccinelle
Semantic patch used to solve the problem is as follows
My personal idea...There are still several other places which use NULL comparisions introduced by the erofs original code, eg, super.c
53: if (vi == NULL)
90: if (bh == NULL) {
...
internal.h
480: if (unlikely(bio == NULL)) {
488: } while (unlikely(bio == NULL));
...
Could you have time fix them as much as possible in a patch?
It will simplify erofs commit log since there are similar patches address the same reason but with few fixes...:
staging: erofs: unzip_vle.c: Replace comparison to NULL.
staging: erofs: Modify conditional checks
staging: erofs: formatting fix to NULL comparison
... Thanks in advance...
Thanks,
Gao Xiang
Quoted 32 lines
// <smpl>
@@
expression x;
statement S;
@@x = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\| usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\)(...));
(quoted diff) +1
-1-if(x==NULL) +if(!x)// </smpl>
Signed-off-by Bhanusree Pola <bhanusreemahesh at gmail.com>--- drivers/staging/erofs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/erofs/xattr.c +1
-1@@ -107,7 +107,7 @@ static int init_inode_xattrs(struct inode *inode) vi->xattr_shared_count = ih->h_shared_count; vi->xattr_shared_xattrs =kmalloc_array (vi->xattr_shared_count,sizeof (uint),GFP_KERNEL ); -if (vi->xattr_shared_xattrs ==NULL ) { +if (!vi->xattr_shared_xattrs) {xattr_iter_end (&it, atomic_map); ret = -ENOMEM ; goto out_unlock;
Quoted 27 lines · Gao Xiang
Hi Bhanusree,
Quoted 6 lines · Bhanusree Pola
Test for NULL as !x instead of NULL comparisions for functions that return NULL on failure are used. Issue found using coccinelle
Semantic patch used to solve the problem is as followsMy personal idea...There are still several other places which use NULL comparisions introduced by the erofs original code, eg,
super.c
53: if (vi == NULL)
90: if (bh == NULL) {
...
internal.h
480: if (unlikely(bio == NULL)) {
488: } while (unlikely(bio == NULL));
...Could you have time fix them as much as possible in a patch?
Quoted 8 lines
It will simplify erofs commit log since there are similar patches address the same reason but with few fixes...:
staging: erofs:
unzip_vle.c: Replace comparison to NULL.
staging: erofs: Modify conditional checks
staging: erofs: formatting fix to NULL comparison... Thanks in advance...
Sure!! I?ll do that and resend.
Bhanusree
Quoted 43 lines
Thanks,
Gao XiangQuoted 32 lines
// <smpl>
@@
expression x;
statement S;
@@x = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\| usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\)(...));
(quoted diff) +1
-1-if(x==NULL) +if(!x)// </smpl>
Signed-off-by Bhanusree Pola <bhanusreemahesh at gmail.com>---
drivers/staging/erofs/xattr.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/erofs/xattr.c +1
-1@@ -107,7 +107,7 @@ static int init_inode_xattrs(struct inode *inode) vi->xattr_shared_count = ih->h_shared_count; vi->xattr_shared_xattrs =kmalloc_array (vi->xattr_shared_count,sizeof (uint),GFP_KERNEL ); -if (vi->xattr_shared_xattrs ==NULL ) { +if (!vi->xattr_shared_xattrs) {xattr_iter_end (&it, atomic_map); ret = -ENOMEM ; goto out_unlock;Signature · 5 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 outreachy-kernel+unsubscribe at googlegroups.com. To post to this group, send email to outreachy-kernel at googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/0a20b616-b2b9-9e38-3c0c-c8860cc41a0c%40huawei.com. For more options, visit https://groups.google.com/d/optout.