linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sh: fix syscall_set_return_value()
@ 2018-12-03  3:18 Dmitry V. Levin
  0 siblings, 0 replies; only message in thread
From: Dmitry V. Levin @ 2018-12-03  3:18 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker
  Cc: Elvira Khabirova, Eugene Syromyatnikov, linux-sh, linux-kernel

According to documentation in include/asm-generic/syscall.h,
if error argument of syscall_set_return_value() is nonzero,
it is a negated errno.

This change fixes syscall_set_return_value() implementation on sh
to match its own syscall_get_error(), the documentation, and other
architectures where error argument of syscall_set_return_value()
is non-positive.

Fixes: fb4f87a2f048b ("sh: Provide the asm/syscall.h interface, needed by tracehook.")
Fixes: 94e2fb3d3e1f4 ("sh: Provide asm/syscall.h for SH-5.")
Cc: stable@vger.kernel.org # v2.6.28+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/sh/include/asm/syscall_32.h | 5 +----
 arch/sh/include/asm/syscall_64.h | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 6e118799831c..5d636a3593d1 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -40,10 +40,7 @@ static inline void syscall_set_return_value(struct task_struct *task,
 					    struct pt_regs *regs,
 					    int error, long val)
 {
-	if (error)
-		regs->regs[0] = -error;
-	else
-		regs->regs[0] = val;
+	regs->regs[0] = error ?: val;
 }
 
 static inline void syscall_get_arguments(struct task_struct *task,
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h
index 43882580c7f9..799fe72316e2 100644
--- a/arch/sh/include/asm/syscall_64.h
+++ b/arch/sh/include/asm/syscall_64.h
@@ -39,10 +39,7 @@ static inline void syscall_set_return_value(struct task_struct *task,
 					    struct pt_regs *regs,
 					    int error, long val)
 {
-	if (error)
-		regs->regs[9] = -error;
-	else
-		regs->regs[9] = val;
+	regs->regs[9] = error ?: val;
 }
 
 static inline void syscall_get_arguments(struct task_struct *task,
-- 
ldv

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-03  3:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-03  3:18 [PATCH] sh: fix syscall_set_return_value() Dmitry V. Levin

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