[1/1] x86/mm: Refine mmap syscall implementation
diff mbox series

Message ID 20201217052648.24656-1-adrianhuang0701@gmail.com
State Accepted
Commit 91a8f6cb06b33adc79fbf5f7381d907485767c00
Headers show
Series
  • [1/1] x86/mm: Refine mmap syscall implementation
Related show

Commit Message

Adrian Huang Dec. 17, 2020, 5:26 a.m. UTC
From: Adrian Huang <ahuang12@lenovo.com>

It is unnecessary to use the local variable 'error' in the mmap
syscall implementation function, so use the return statement
instead of it.

Signed-off-by: Adrian Huang <ahuang12@lenovo.com>
---
 arch/x86/kernel/sys_x86_64.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Christoph Hellwig Dec. 22, 2020, 2:51 p.m. UTC | #1
On Thu, Dec 17, 2020 at 01:26:48PM +0800, Adrian Huang wrote:
> From: Adrian Huang <ahuang12@lenovo.com>
> 
> It is unnecessary to use the local variable 'error' in the mmap
> syscall implementation function, so use the return statement
> instead of it.

I'm normally not a fan of standalone cleanup patches, but this one
actually improves the function a lot, so:

Reviewed-by: Christoph Hellwig <hch@lst.de>

Patch
diff mbox series

diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 504fa5425bce..660b78827638 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -90,14 +90,10 @@  SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
 		unsigned long, prot, unsigned long, flags,
 		unsigned long, fd, unsigned long, off)
 {
-	long error;
-	error = -EINVAL;
 	if (off & ~PAGE_MASK)
-		goto out;
+		return -EINVAL;
 
-	error = ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
-out:
-	return error;
+	return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
 }
 
 static void find_start_end(unsigned long addr, unsigned long flags,