[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241118153047.7e90015f@gandalf.local.home>
Date: Mon, 18 Nov 2024 15:30:47 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>
Cc: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, linux-kernel@...r.kernel.org,
dietmar.eggemann@....com, bsegall@...gle.com, mgorman@...e.de,
vschneid@...hat.com
Subject: Re: [PATCH sched-next] sched/cputime: Fix unused value issue
On Mon, 18 Nov 2024 16:43:14 +0530
Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com> wrote:
> This commit fixes an unused value issue detected by Coverity
> (CID 1357987). The value of utime is updated but has no use as it is
> updated later on without using the stored value.
>
> Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>
> ---
> kernel/sched/cputime.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 0bed0fa1acd9..3dea3636a260 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -571,13 +571,9 @@ void cputime_adjust(struct task_cputime *curr, struct prev_cputime *prev,
> * Once a task gets some ticks, the monotonicity code at 'update:'
> * will ensure things converge to the observed ratio.
> */
> - if (stime == 0) {
> - utime = rtime;
> - goto update;
> - }
> -
> - if (utime == 0) {
> - stime = rtime;
> + if (stime == 0 || utime == 0) {
> + if (utime == 0)
> + stime = rtime;
> goto update;
> }
>
The above adds more branches than just having:
if (stime == 0)
goto update;
if (utime == 0) {
stime = rtime;
goto update;
}
(or's "||" are branches)
And the latter is much easier to read!
Just fix the issue. Don't try to be clever about it.
-- Steve
Powered by blists - more mailing lists