* [PATCH] filesystems: Simplify if conditional statements
@ 2023-01-05 6:18 Li zeming
0 siblings, 0 replies; only message in thread
From: Li zeming @ 2023-01-05 6:18 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel, Li zeming
When the * p pointer is null, assign a value to res; otherwise, do not
execute the content in the conditional statement block.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
fs/filesystems.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/filesystems.c b/fs/filesystems.c
index 58b9067b2391..1839dcd6cfbd 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -71,7 +71,7 @@ static struct file_system_type **find_filesystem(const char *name, unsigned len)
int register_filesystem(struct file_system_type * fs)
{
- int res = 0;
+ int res = -EBUSY;
struct file_system_type ** p;
if (fs->parameters &&
@@ -83,10 +83,10 @@ int register_filesystem(struct file_system_type * fs)
return -EBUSY;
write_lock(&file_systems_lock);
p = find_filesystem(fs->name, strlen(fs->name));
- if (*p)
- res = -EBUSY;
- else
+ if (!*p) {
+ res = 0;
*p = fs;
+ }
write_unlock(&file_systems_lock);
return res;
}
--
2.18.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-05 6:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 6:18 [PATCH] filesystems: Simplify if conditional statements Li zeming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).