[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1394032656.3271.51.camel@joe-AO722>
Date: Wed, 05 Mar 2014 07:17:36 -0800
From: Joe Perches <joe@...ches.com>
To: Dongsheng Yang <yangds.fnst@...fujitsu.com>
Cc: linux-kernel@...r.kernel.org, fweisbec@...il.com,
rostedt@...dmis.org, peterz@...radead.org, mingo@...hat.com,
Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH 2/3] sched: Use clamp() and clamp_val() to make it more
readable.
On Wed, 2014-03-05 at 20:36 +0800, Dongsheng Yang wrote:
> As Kees suggested, I use clamp() function to replace the if and
> else branch, making it more readable and modular.
>
> Suggested-by: Kees Cook <keescook@...omium.org>
> Signed-off-by: Dongsheng Yang <yangds.fnst@...fujitsu.com>
[]
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
[]
> @@ -3070,17 +3070,10 @@ SYSCALL_DEFINE1(nice, int, increment)
> * We don't have to worry. Conceptually one call occurs first
> * and we have a single winner.
> */
> - if (increment < -40)
> - increment = -40;
> - if (increment > 40)
> - increment = 40;
> -
> + increment = clamp(increment, -40, 40);
Maybe:
increment = clamp(increment, -(NICE_MAX - NICE_MIN + 1),
, NICE_MAX - NICE_MIN + 1)
or add yet another define like #define NICE_RANGE
or #define NICE_MAX_INCREMENT
--
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