[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5j+wSEnWAwgUBM47C8TXiEzmJt-J6sGHNEewwXqb5FgGEA@mail.gmail.com>
Date: Tue, 11 Feb 2014 10:27:48 -0800
From: Kees Cook <keescook@...omium.org>
To: Dongsheng Yang <yangds.fnst@...fujitsu.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>, Robin Holt <holt@....com>,
Al Viro <viro@...iv.linux.org.uk>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE
and MAX_NICE.
On Mon, Feb 10, 2014 at 11:34 PM, Dongsheng Yang
<yangds.fnst@...fujitsu.com> wrote:
> Signed-off-by: Dongsheng Yang <yangds.fnst@...fujitsu.com>
> cc: Andrew Morton <akpm@...ux-foundation.org>
> cc: Oleg Nesterov <oleg@...hat.com>
> cc: Robin Holt <holt@....com>
> cc: Al Viro <viro@...iv.linux.org.uk>
> cc: Kees Cook <keescook@...omium.org>
> cc: "Eric W. Biederman" <ebiederm@...ssion.com>
> cc: Stephen Rothwell <sfr@...b.auug.org.au>
> cc: Peter Zijlstra <peterz@...radead.org>
> cc: Ingo Molnar <mingo@...nel.org>
> ---
> kernel/sys.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sys.c b/kernel/sys.c
> index c0a58be..adaeab6 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -174,10 +174,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
>
> /* normalize: avoid signed division (rounding problems) */
> error = -ESRCH;
> - if (niceval < -20)
> - niceval = -20;
> - if (niceval > 19)
> - niceval = 19;
> + if (niceval < MIN_NICE)
> + niceval = MIN_NICE;
> + if (niceval > MAX_NICE)
> + niceval = MAX_NICE;
Good catch! I'm all for using names instead of numeric values,
however, I wonder if it'd be more readable to use "clamp" instead?
niceval = clamp(niceval, MIN_NICE, MAX_NICE);
-Kees
>
> rcu_read_lock();
> read_lock(&tasklist_lock);
> --
> 1.8.2.1
>
--
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists