lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241119083650.GD11903@noisy.programming.kicks-ass.net>
Date: Tue, 19 Nov 2024 09:36:50 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>,
	mingo@...hat.com, 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, Nov 18, 2024 at 03:30:47PM -0500, Steven Rostedt wrote:
> 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.

There is nothing to fix. Yes there is an unused assignment, but the
compiler is free to elide it (and it does).

Keep the code as is, it is simple and straight-forward.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ