Skip to contentSkip to conversation

use defines in sys_getpriority/sys_setpriority

PATCH In review Daniel Walker 2 participants 2 messages May 10, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use defines in sys_getpriority/sys_setpriority

Switch to the defines for these two checks, instead of hard coding the values.

---
 kernel/sys.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sys.c +2 -2
Index: linux-2.6.21/kernel/sys.c
===================================================================
@@ -598,7 +598,7 @@ asmlinkage long sys_setpriority(int whic
 	int error = -EINVAL;
 	struct pid *pgrp;
 
-	if (which > 2 || which < 0)
+	if (which > PRIO_USER || which < PRIO_PROCESS)
 		goto out;
 
 	/* normalize: avoid signed division (rounding problems) */
@@ -662,7 +662,7 @@ asmlinkage long sys_getpriority(int whic
 	long niceval, retval = -ESRCH;
 	struct pid *pgrp;
 
-	if (which > 2 || which < 0)
+	if (which > PRIO_USER || which < PRIO_PROCESS)
 		return -EINVAL;
 
 	read_lock(&tasklist_lock);
Signature · 1 line
-- 
#1 lore raw
Quoted 23 lines · On Thu, 10 May 2007 10:22:23 -0700 Daniel Walker <[email protected]> wrote:

Switch to the defines for these two checks, instead of hard coding the values.

---
 kernel/sys.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6.21/kernel/sys.c
===================================================================

kernel/sys.c +1 -1
@@ -598,7 +598,7 @@ asmlinkage long sys_setpriority(int whic
 	int error = -EINVAL;
 	struct pid *pgrp;
 
-	if (which > 2 || which < 0)
+	if (which > PRIO_USER || which < PRIO_PROCESS)
 		goto out;
 
 	/* normalize: avoid signed division (rounding problems) */

kernel/sys.c asmlinkage long sys_getpriority(int whic · line 668

Quoted 8 lines
kernel/sys.c +1 -1
@@ -662,7 +662,7 @@ asmlinkage long sys_getpriority(int whic
 	long niceval, retval = -ESRCH;
 	struct pid *pgrp;
 
-	if (which > 2 || which < 0)
+	if (which > PRIO_USER || which < PRIO_PROCESS)
 		return -EINVAL;
 
 	read_lock(&tasklist_lock);

I added this:

kernel/sys.c renamed from kernel/sys.c~use-defines-in-sys_getpriority-sys_setpriority-fix +1 -0
@@ -14,6 +14,7 @@
 #include <linux/prctl.h>
 #include <linux/highuid.h>
 #include <linux/fs.h>
+#include <linux/resource.h>
 #include <linux/kernel.h>
 #include <linux/kexec.h>
 #include <linux/workqueue.h>

_