From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02730C43381 for ; Wed, 27 Feb 2019 10:32:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4D1B20830 for ; Wed, 27 Feb 2019 10:32:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jZ/MBf4B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729590AbfB0Kcf (ORCPT ); Wed, 27 Feb 2019 05:32:35 -0500 Received: from merlin.infradead.org ([205.233.59.134]:33368 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbfB0Kcf (ORCPT ); Wed, 27 Feb 2019 05:32:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HEBS+wqoEJPAVXiPq/KTjkfKwckdCL55HqqC6cnjV1w=; b=jZ/MBf4BnByxShW5GN/fMmzwT qqhyP7/QUeRjd+c0aApOAKx66bxk5TezFy5DXVb0imQqrEStTKOX924xVlJqBCfwf5qYzb7UXxxdk 1r9MrdtRRI0xgh2gKqkik/MKWFVXWM/UlTBJn19Tcjux2SjuWfg66yJK5jIxoYSPGNdHUfMewwd60 p2NABGFPnA3mKxGJH+jR6kH1kEBVCfRNbhJ9h2aY5auky6evZk/WeP+B2BzTwPiSw8zsVMl6s9GOy /9RiZgyI2i4880qEyo9EZ9zjKx2V55iAkFKk+//NeghIc7UMXXYq76How75XQWsBwKhe42zrkOvyr f1XGinHGQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gywVs-000804-0o; Wed, 27 Feb 2019 10:32:32 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BC6EE200F9F95; Wed, 27 Feb 2019 11:32:30 +0100 (CET) Date: Wed, 27 Feb 2019 11:32:30 +0100 From: Peter Zijlstra To: Ketan Patil Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, snikam@nvidia.com, bnihalani@nvidia.com, byan@nvidia.com, sgurrappadi@nvidia.com, treding@nvidia.com, talho@nvidia.com Subject: Re: [PATCH] sched/cputime: Remove unnecessary assignment statement Message-ID: <20190227103230.GM32494@hirez.programming.kicks-ass.net> References: <1551248002-27303-1-git-send-email-ketanp@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551248002-27303-1-git-send-email-ketanp@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Ketan Patil > --- > 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;