All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <gorcunov@gmail.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] sys_prctl(): remove unsigned comparision with less than zero
Date: Thu, 25 Jul 2019 11:10:56 +0800	[thread overview]
Message-ID: <5D391DC0.3050100@cn.fujitsu.com> (raw)
In-Reply-To: <20190724191448.4db70a34f8b89bd8bdc085f5@linux-foundation.org>

on 2019/07/25 10:14, Andrew Morton wrote:

> On Wed, 24 Jul 2019 10:11:48 +0800 Yang Xu<xuyang2018.jy@cn.fujitsu.com>  wrote:
>
>> Currently, when calling prctl(PR_SET_TIMERSLACK, arg2), arg2 is an
>> unsigned long value, arg2 will never<  0. Negative judgment is
>> meaningless, so remove it.
>>
>> ...
>>
>> --- a/kernel/sys.c
>> +++ b/kernel/sys.c
>> @@ -2372,7 +2372,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
>>   			error = current->timer_slack_ns;
>>   		break;
>>   	case PR_SET_TIMERSLACK:
>> -		if (arg2<= 0)
>> +		if (arg2 == 0)
>>   			current->timer_slack_ns =
>>   					current->default_timer_slack_ns;
> A number of years ago Linus expressed approval of such comparisons with
> unsigned quantities.  He felt that it improves readability a little -
> the reader doesn't have to scroll back and check the type.
Hi Andrew

    It sounds good. ButWe still have to look at the actual situation. In here, this comparisons with unsigned
quantities doesn't improvereadability. In turn, the code give user a wrongdescription  as man page said "
If arg2 is less than or equal to zero, the "current" timer slack is reset to the thread's default" timer slack value."

If we set -1 in user space, we pass it into kernel as ULONG_MAX, it will not use default timer_slack value.

Also, I guess that if value has no actual sense we can use this comparisons. In here, arg2 represents slack time.
time will never less than 0.

ps: whether we change or not change this comparisons, it doesn't affect logic. So if you think this patch is meaningless,
I will accept it.

Thanks
Yang Xu

>
>
>
>




  reply	other threads:[~2019-07-25  3:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23  3:30 [PATCH] sys_prctl(): simplify arg2 judgment when calling PR_SET_TIMERSLACK Yang Xu
2019-07-23  7:23 ` Cyrill Gorcunov
2019-07-23  8:11   ` Yang Xu
2019-07-23  9:48     ` Cyrill Gorcunov
2019-07-24  2:11       ` [PATCH v2] sys_prctl(): remove unsigned comparision with less than zero Yang Xu
2019-07-24  6:56         ` Cyrill Gorcunov
2019-07-25  2:14         ` Andrew Morton
2019-07-25  3:10           ` Yang Xu [this message]
2019-07-30  8:48             ` Yang Xu

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=5D391DC0.3050100@cn.fujitsu.com \
    --to=xuyang2018.jy@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.