mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: liguang <lig.fnst@cn.fujitsu.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	David Howells <dhowells@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Dave Jones <davej@redhat.com>, Kees Cook <keescook@chromium.org>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] sys: remove unnecesscary parameter of set_one_prio
Date: Fri, 31 May 2013 15:53:51 -0700	[thread overview]
Message-ID: <20130531155351.830389cd15a543377fbaf289@linux-foundation.org> (raw)
In-Reply-To: <1369900686-5936-1-git-send-email-lig.fnst@cn.fujitsu.com>

On Thu, 30 May 2013 15:58:03 +0800 liguang <lig.fnst@cn.fujitsu.com> wrote:

> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  kernel/sys.c |   12 +++++-------
>  1 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/sys.c b/kernel/sys.c
> index b95d3c7..07c6177 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -151,9 +151,9 @@ static bool set_one_prio_perm(struct task_struct *p)
>   * set the priority of a task
>   * - the caller must hold the RCU read lock
>   */
> -static int set_one_prio(struct task_struct *p, int niceval, int error)
> +static int set_one_prio(struct task_struct *p, int niceval)
>  {
> -	int no_nice;
> +	int no_nice, error = 0;
>  
>  	if (!set_one_prio_perm(p)) {
>  		error = -EPERM;
> @@ -168,8 +168,6 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
>  		error = no_nice;
>  		goto out;
>  	}
> -	if (error == -ESRCH)
> -		error = 0;
>  	set_user_nice(p, niceval);
>  out:
>  	return error;
> @@ -203,7 +201,7 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
>  			else
>  				p = current;
>  			if (p)
> -				error = set_one_prio(p, niceval, error);
> +				error = set_one_prio(p, niceval);
>  			break;
>  		case PRIO_PGRP:
>  			if (who)
> @@ -211,7 +209,7 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
>  			else
>  				pgrp = task_pgrp(current);
>  			do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
> -				error = set_one_prio(p, niceval, error);
> +				error = set_one_prio(p, niceval);
>  			} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
>  			break;
>  		case PRIO_USER:
> @@ -225,7 +223,7 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
>  
>  			do_each_thread(g, p) {
>  				if (uid_eq(task_uid(p), uid))
> -					error = set_one_prio(p, niceval, error);
> +					error = set_one_prio(p, niceval);
>  			} while_each_thread(g, p);
>  			if (!uid_eq(uid, cred->uid))
>  				free_uid(user);		/* For find_user() */

Yes, that apepars to be an evuivalent change, but only because
security_task_setnice() cannot return -ESRCH.  The existing code is
rather awkward.

A couple of changes:

From: Andrew Morton <akpm@linux-foundation.org>
Subject: kernel-sysc-remove-unnecessary-parameter-of-set_one_prio-fix

clean up definitions, remove unneeded assignment

Cc: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

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

diff -puN kernel/sys.c~kernel-sysc-remove-unnecessary-parameter-of-set_one_prio-fix kernel/sys.c
--- a/kernel/sys.c~kernel-sysc-remove-unnecessary-parameter-of-set_one_prio-fix
+++ a/kernel/sys.c
@@ -153,7 +153,8 @@ static bool set_one_prio_perm(struct tas
  */
 static int set_one_prio(struct task_struct *p, int niceval)
 {
-	int no_nice, error = 0;
+	int no_nice;
+	int error = 0;
 
 	if (!set_one_prio_perm(p)) {
 		error = -EPERM;
@@ -186,7 +187,6 @@ SYSCALL_DEFINE3(setpriority, int, which,
 		goto out;
 
 	/* normalize: avoid signed division (rounding problems) */
-	error = -ESRCH;
 	if (niceval < -20)
 		niceval = -20;
 	if (niceval > 19)
_


      parent reply	other threads:[~2013-05-31 22:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30  7:58 liguang
2013-05-30  7:58 ` [PATCH 2/4] sys: remove kernel_shutdown_prepare's parameter liguang
2013-05-31 22:58   ` Andrew Morton
2013-05-30  7:58 ` [PATCH 3/4] sys/reboot: boolize C_A_D liguang
2013-05-31 23:02   ` Andrew Morton
2013-06-03  0:25     ` li guang
2013-06-03  1:09     ` Joe Perches
2013-05-30  7:58 ` [PATCH 4/4] sys: fix malformed panic massage of reboot liguang
2013-05-30  8:08 ` [PATCH 1/4] sys: remove unnecesscary parameter of set_one_prio Joe Perches
2013-05-31 23:07   ` Andrew Morton
2013-05-31 22:53 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130531155351.830389cd15a543377fbaf289@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=gorcunov@openvz.org \
    --cc=keescook@chromium.org \
    --cc=lig.fnst@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®