linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] x86/mm: Refine mmap syscall implementation
@ 2020-12-17  5:26 Adrian Huang
  2020-12-22 14:51 ` Christoph Hellwig
  2021-01-05 18:28 ` [tip: x86/cleanups] " tip-bot2 for Adrian Huang
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian Huang @ 2020-12-17  5:26 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	Adrian Huang, Adrian Huang

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(-)

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,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] x86/mm: Refine mmap syscall implementation
  2020-12-17  5:26 [PATCH 1/1] x86/mm: Refine mmap syscall implementation Adrian Huang
@ 2020-12-22 14:51 ` Christoph Hellwig
  2021-01-05 18:28 ` [tip: x86/cleanups] " tip-bot2 for Adrian Huang
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-12-22 14:51 UTC (permalink / raw)
  To: Adrian Huang
  Cc: linux-kernel, x86, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H . Peter Anvin, Adrian Huang

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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: x86/cleanups] x86/mm: Refine mmap syscall implementation
  2020-12-17  5:26 [PATCH 1/1] x86/mm: Refine mmap syscall implementation Adrian Huang
  2020-12-22 14:51 ` Christoph Hellwig
@ 2021-01-05 18:28 ` tip-bot2 for Adrian Huang
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Adrian Huang @ 2021-01-05 18:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Adrian Huang, Borislav Petkov, Christoph Hellwig, x86, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     91a8f6cb06b33adc79fbf5f7381d907485767c00
Gitweb:        https://git.kernel.org/tip/91a8f6cb06b33adc79fbf5f7381d907485767c00
Author:        Adrian Huang <ahuang12@lenovo.com>
AuthorDate:    Thu, 17 Dec 2020 13:26:48 +08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Tue, 05 Jan 2021 19:07:42 +01:00

x86/mm: Refine mmap syscall implementation

It is unnecessary to use the local variable 'error' in the mmap syscall
implementation function - just return -EINVAL directly and get rid of
the local variable altogether.

 [ bp: Massage commit message. ]

Signed-off-by: Adrian Huang <ahuang12@lenovo.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lkml.kernel.org/r/20201217052648.24656-1-adrianhuang0701@gmail.com
---
 arch/x86/kernel/sys_x86_64.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 504fa54..660b788 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,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-05 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17  5:26 [PATCH 1/1] x86/mm: Refine mmap syscall implementation Adrian Huang
2020-12-22 14:51 ` Christoph Hellwig
2021-01-05 18:28 ` [tip: x86/cleanups] " tip-bot2 for Adrian Huang

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).