Skip to contentSkip to conversation

Remove unneeded code in sys_getpriority

PATCH In review Rabin Vincent 2 participants 4 messages Feb 3, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove unneeded code in sys_getpriority

This check is not required because the condition is always true.

---
 kernel/sys.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
kernel/sys.c +2 -5
index d1fe71e..a001974 100644
@@ -212,11 +212,8 @@ asmlinkage long sys_getpriority(int which, int who)
 				p = find_task_by_vpid(who);
 			else
 				p = current;
-			if (p) {
-				niceval = 20 - task_nice(p);
-				if (niceval > retval)
-					retval = niceval;
-			}
+			if (p)
+				retval = 20 - task_nice(p);
 			break;
 		case PRIO_PGRP:
 			if (who)
Signature · 1 line
1.5.3.8
#1 lore raw

kernel/sys.c asmlinkage long sys_getpriority(int which, int who) · line 216

Quoted 5 lines · Rabin Vincent

This check is not required because the condition is always true.
...

kernel/sys.c +1 -2
-				if (niceval > retval)
-					retval = niceval;
+				retval = 20 - task_nice(p);

Thats surely correct, but on the other hand currently those case blocks are quite independet of their possition/could easily be rearranged now .. or think of another case is put ahead. Then this could mess up things.

Thanks,
Frank

#2 lore raw
Quoted 11 lines · Frank Seidel

kernel/sys.c asmlinkage long sys_getpriority(int which, int who) · line 216

Quoted 5 lines · Rabin Vincent

This check is not required because the condition is always true.
...

kernel/sys.c +1 -2
-				if (niceval > retval)
-					retval = niceval;
+				retval = 20 - task_nice(p);

Thats surely correct, but on the other hand currently those case blocks are quite independet of their possition/could easily be rearranged now .. or think of another case is put ahead. Then this could mess up things.

Do you mean the PRIO_* cases in the switch? They're still independent of position after the patch because they don't fall through.

Quoted 2 lines

Thanks,
Frank

Rabin

#3 lore raw
Quoted 2 lines · Rabin Vincent

Do you mean the PRIO_* cases in the switch? They're still independent of position after the patch because they don't fall through.

Yes, sure, this is fully correct now. Just if somehting whatsoever is put ahead touching retval one need to take care of this here. But as i don't have enough experience to know if this likely at all i'm fully fine with it. Just wanted to note one should think about if its worth the change.

Thanks,
Frank