Skip to contentSkip to conversation

MIPS: Fine-tuning for three function implementations

PATCH New SF Markus Elfring 1 participant 4 messages Jan 18, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover MIPS: Fine-tuning for three function implementations

From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 19:43:34 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Return directly in 32_mmap2()
Move an assignment for the variable "retval" in mipsmt_sys_sched_setaffinity() Return directly in mips_mmap()

 arch/mips/kernel/linux32.c       | 11 +++--------
 arch/mips/kernel/mips-mt-fpaff.c |  5 +++--
 arch/mips/kernel/syscall.c       | 11 ++---------
 3 files changed, 8 insertions(+), 19 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/3 MIPS: Return directly in 32_mmap2()

From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 19:00:05 +0100

* Return a failure indication without storing it
in an intermediate variable.

* Delete the local variable "error" which became unnecessary with this refactoring.

---
 arch/mips/kernel/linux32.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
arch/mips/kernel/linux32.c +3 -8
index 50fb62544df7..6fa6cdfa6e22 100644
@@ -64,15 +64,10 @@ SYSCALL_DEFINE6(32_mmap2, unsigned long, addr, unsigned long, len,
 	unsigned long, prot, unsigned long, flags, unsigned long, fd,
 	unsigned long, pgoff)
 {
-	unsigned long error;
-
-	error = -EINVAL;
 	if (pgoff & (~PAGE_MASK >> 12))
-		goto out;
-	error = sys_mmap_pgoff(addr, len, prot, flags, fd,
-			       pgoff >> (PAGE_SHIFT-12));
-out:
-	return error;
+		return -EINVAL;
+	return sys_mmap_pgoff(addr, len, prot, flags, fd,
+			      pgoff >> (PAGE_SHIFT-12));
 }
 
 #define RLIM_INFINITY32 0x7fffffff
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/3 MIPS: MT: Move an assignment for the variable "retval" in mipsmt_sys_sched_setaffinity()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 19:18:37 +0100

A local variable was set to an error code in one case before a concrete error situation was detected. Thus move the corresponding assignment into an if branch to indicate a software failure there.

This issue was detected by using the Coccinelle software.

---
 arch/mips/kernel/mips-mt-fpaff.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/kernel/mips-mt-fpaff.c +3 -2
index 789d7bf4fef3..ddde22787287 100644
@@ -99,9 +99,10 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
 		retval = -ENOMEM;
 		goto out_free_new_mask;
 	}
-	retval = -EPERM;
-	if (!check_same_owner(p) && !capable(CAP_SYS_NICE))
+	if (!check_same_owner(p) && !capable(CAP_SYS_NICE)) {
+		retval = -EPERM;
 		goto out_unlock;
+	}
 
 	retval = security_task_setscheduler(p);
 	if (retval)
Signature · 1 line
2.11.0
#3 lore raw

PATCH 3/3 MIPS-syscall: Return directly in mips_mmap()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 19:30:47 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "result" which became unnecessary with this refactoring.

---
 arch/mips/kernel/syscall.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
arch/mips/kernel/syscall.c +2 -9
index 53a7ef9a8f32..e4e99888799d 100644
@@ -60,16 +60,9 @@ SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len,
 	unsigned long, prot, unsigned long, flags, unsigned long,
 	fd, off_t, offset)
 {
-	unsigned long result;
-
-	result = -EINVAL;
 	if (offset & ~PAGE_MASK)
-		goto out;
-
-	result = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
-
-out:
-	return result;
+		return -EINVAL;
+	return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
 }
 
 SYSCALL_DEFINE6(mips_mmap2, unsigned long, addr, unsigned long, len,
Signature · 1 line
2.11.0