lkml.org 
[lkml]   [2019]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] sys_prctl(): remove unsigned comparision with less than zero
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

>
>
>
>



\
 
 \ /
  Last update: 2019-07-25 05:12    [W:0.980 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site