[PATCH] coredump: simplify coredump_skip()

Fushuai Wang posted 1 patch 1 month, 3 weeks ago
fs/coredump.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
[PATCH] coredump: simplify coredump_skip()
Posted by Fushuai Wang 1 month, 3 weeks ago
Replace the multi-if conditional check with a single return statement.

Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
 fs/coredump.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index fedbead956ed..3fcbf108099b 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1077,13 +1077,8 @@ static void coredump_cleanup(struct core_name *cn, struct coredump_params *cprm)
 static inline bool coredump_skip(const struct coredump_params *cprm,
 				 const struct linux_binfmt *binfmt)
 {
-	if (!binfmt)
-		return true;
-	if (!binfmt->core_dump)
-		return true;
-	if (!__get_dumpable(cprm->mm_flags))
-		return true;
-	return false;
+	return (!binfmt || !binfmt->core_dump ||
+		!__get_dumpable(cprm->mm_flags));
 }
 
 void vfs_coredump(const kernel_siginfo_t *siginfo)
-- 
2.36.1
Re: [PATCH] coredump: simplify coredump_skip()
Posted by Christian Brauner 1 month, 3 weeks ago
On Mon, Aug 11, 2025 at 03:51:55PM +0800, Fushuai Wang wrote:
> Replace the multi-if conditional check with a single return statement.
> 
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> ---

This is a matter of taste. Thanks for the idea but the checks on
separate lines make it easier to read.