lkml.org 
[lkml]   [2019]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] sched/cputime: Remove unnecessary assignment statement
From
Date
The coverity tool has detected this issue as an unused value, since

the code assigns the value to utime variable and then after the jump, the

value of utime again gets updated, hence the previous value is not at all

useful and this patch removes that first assignment.

On 27/02/19 4:02 PM, Peter Zijlstra wrote:
> On Wed, Feb 27, 2019 at 11:43:22AM +0530, Ketan Patil wrote:
>> The original code assigns the value from rtime to utime variable,
>> and then jumps to the update label. And the value of utime is then
>> updated, so the earlier value of utime is not used. Hence remove
>> that unnecessary assignment statement.
>>
>> This fixes one of the coverity defects.
> Why does coverity care? I like the way the code is now, it makes
> conceptual sense. Removing that assignment makes the code harder to read
> and less symmetric (see the utime case right below).
>
> Any sensible compiler will 'fix' this for us anyway.
>
>> Based on work by Ishan Mittal <imittal@nvidia.com>
>> Signed-off-by: Ketan Patil <ketanp@nvidia.com>
>> ---
>> kernel/sched/cputime.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
>> index ba4a143..ad64771 100644
>> --- a/kernel/sched/cputime.c
>> +++ b/kernel/sched/cputime.c
>> @@ -616,10 +616,8 @@ void cputime_adjust(struct task_cputime *curr, struct prev_cputime *prev,
>> * Once a task gets some ticks, the monotonicy code at 'update:'
>> * will ensure things converge to the observed ratio.
>> */
>> - if (stime == 0) {
>> - utime = rtime;
>> + if (stime == 0)
>> goto update;
>> - }
>>
>> if (utime == 0) {
>> stime = rtime;

\
 
 \ /
  Last update: 2019-02-28 10:44    [W:0.063 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site