Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751738AbaBLD7q (ORCPT ); Tue, 11 Feb 2014 22:59:46 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:50001 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751186AbaBLD7o (ORCPT ); Tue, 11 Feb 2014 22:59:44 -0500 X-IronPort-AV: E=Sophos;i="4.95,829,1384272000"; d="scan'208";a="9510970" Message-ID: <52FAF1A0.8040605@cn.fujitsu.com> Date: Wed, 12 Feb 2014 11:59:28 +0800 From: Dongsheng Yang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130612 Thunderbird/17.0.6 MIME-Version: 1.0 To: Kees Cook CC: LKML , Andrew Morton , Oleg Nesterov , Robin Holt , Al Viro , "Eric W. Biederman" , Stephen Rothwell , Peter Zijlstra , Ingo Molnar Subject: Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE. References: <0261f094b836f1acbcdf52e7166487c0c77323c8.1392103744.git.yangds.fnst@cn.fujitsu.com> In-Reply-To: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/02/12 11:57:36, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/02/12 11:57:42, Serialize complete at 2014/02/12 11:57:42 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kees, On 02/12/2014 02:27 AM, Kees Cook wrote: > On Mon, Feb 10, 2014 at 11:34 PM, Dongsheng Yang > wrote: >> Signed-off-by: Dongsheng Yang >> cc: Andrew Morton >> cc: Oleg Nesterov >> cc: Robin Holt >> cc: Al Viro >> cc: Kees Cook >> cc: "Eric W. Biederman" >> cc: Stephen Rothwell >> cc: Peter Zijlstra >> cc: Ingo Molnar >> --- >> 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); Good suggestion! This patch here is just to replace the numeric values with a name defined in prio.h. So I will send another patch to make it more readable with clamp after the patch set here applied. Is this plan ok to you? Thanx. > > -Kees > >> rcu_read_lock(); >> read_lock(&tasklist_lock); >> -- >> 1.8.2.1 >> > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/