2022-07-12 15:58:23

by williamsukatube

[permalink] [raw]
Subject: [PATCH -next] ovl: clean up comparsions to NULL

From: William Dean <[email protected]>

Clean up comparsions to NULL, simplify as follows:
if (x == NULL) -> if (!x)

Reported-by: Hacash Robot <[email protected]>
Signed-off-by: William Dean <[email protected]>
---
fs/overlayfs/readdir.c | 6 +++---
fs/overlayfs/super.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 78f62cc1797b..953ff22d825c 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -182,7 +182,7 @@ static int ovl_cache_entry_add_rb(struct ovl_readdir_data *rdd,
return 0;

p = ovl_cache_entry_new(rdd, name, len, ino, d_type);
- if (p == NULL) {
+ if (!p) {
rdd->err = -ENOMEM;
return -ENOMEM;
}
@@ -205,7 +205,7 @@ static int ovl_fill_lowest(struct ovl_readdir_data *rdd,
list_move_tail(&p->l_node, &rdd->middle);
} else {
p = ovl_cache_entry_new(rdd, name, namelen, ino, d_type);
- if (p == NULL)
+ if (!p)
rdd->err = -ENOMEM;
else
list_add_tail(&p->l_node, &rdd->middle);
@@ -538,7 +538,7 @@ static int ovl_fill_plain(struct dir_context *ctx, const char *name,

rdd->count++;
p = ovl_cache_entry_new(rdd, name, namelen, ino, d_type);
- if (p == NULL) {
+ if (!p) {
rdd->err = -ENOMEM;
return -ENOMEM;
}
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index e0a2e0468ee7..a474cb8040b2 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -468,7 +468,7 @@ static char *ovl_next_opt(char **s)
char *sbegin = *s;
char *p;

- if (sbegin == NULL)
+ if (!sbegin)
return NULL;

for (p = sbegin; *p; p++) {
@@ -2186,7 +2186,7 @@ static int __init ovl_init(void)
(SLAB_RECLAIM_ACCOUNT|
SLAB_MEM_SPREAD|SLAB_ACCOUNT),
ovl_inode_init_once);
- if (ovl_inode_cachep == NULL)
+ if (!ovl_inode_cachep)
return -ENOMEM;

err = ovl_aio_request_cache_init();
--
2.25.1


2022-07-27 13:57:35

by Miklos Szeredi

[permalink] [raw]
Subject: Re: [PATCH -next] ovl: clean up comparsions to NULL

On Tue, 12 Jul 2022 at 17:24, <[email protected]> wrote:
>
> From: William Dean <[email protected]>
>
> Clean up comparsions to NULL, simplify as follows:
> if (x == NULL) -> if (!x)

Again, this has too little worth. NACK.

Thanks,
Miklos