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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B013DC43334 for ; Mon, 20 Jun 2022 19:14:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 296336B0071; Mon, 20 Jun 2022 15:14:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 247266B0073; Mon, 20 Jun 2022 15:14:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15E306B0074; Mon, 20 Jun 2022 15:14:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 02AAC6B0071 for ; Mon, 20 Jun 2022 15:14:32 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C3382326B7 for ; Mon, 20 Jun 2022 19:14:31 +0000 (UTC) X-FDA: 79599565542.20.F561E95 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf28.hostedemail.com (Postfix) with ESMTP id 59A50C00B5 for ; Mon, 20 Jun 2022 19:14:31 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D188821E79; Mon, 20 Jun 2022 19:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655752469; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rw6KyjRPPeRtWJoUjKKFKcXaOYHldsENxBp+suFMN7c=; b=Sj3XbwYTymwKIcMXPyV2VDhNN0yiRuptjqvEc7Js0PkCaSfwAtp9YAlJAz6EblBmbdhVcO 8kCy9Z5rg2iPaPeb3VlrflQbm3N6ZNu3C8btlt/rdJTGhaJeHTdD4ehuQ8a8pqNTEkgO1c OSqQ/zUZClH9CMtre9EEasuxkGb/RXo= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 5255E2C141; Mon, 20 Jun 2022 19:14:29 +0000 (UTC) Date: Mon, 20 Jun 2022 21:14:28 +0200 From: Michal Hocko To: Julia Lawall Cc: Charan Teja Kalla , kernel test robot , Minchan Kim , kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Andrew Morton , Linux Memory Management List Subject: Re: [kbuild-all] Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment] Message-ID: References: <202206180617.UzO7ymnD-lkp@intel.com> <5ec7b561-551b-f02a-9b7b-65d05ccdabbc@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655752471; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rw6KyjRPPeRtWJoUjKKFKcXaOYHldsENxBp+suFMN7c=; b=NzlegqjJERXzRYDN8mrFT/TbbNPBptmbOV7i2RdE8iXjE0YzDw9t53qca2G2+M1xUWXUZG k38IdXfMbVi8z4YyhLT+gJ50cQMNmXHcOheS9cb/oTlAUAm5SMnl3InDRWueh4GDifQgpu WFCvGABaudm4tnh/vGyYSZn0q8VrfrM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=Sj3XbwYT; spf=pass (imf28.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655752471; a=rsa-sha256; cv=none; b=cGBQCiP30nHZq6q2HbAHSNqyO+6eSzY8pnaETpeLquM1RYvyl86C/UXgQSFtypMwRYtL31 ACcEgwf4eJlkoA7wp93Bn84+il+MF5qZI8xNNfo1Ptlq1ntXkgUGBPkdZVbZNtfTHbl2Yj chtLShocZ29Rs0qFdnKp4b9djSJLfhs= X-Stat-Signature: pp57b4kgmt4yturch5o1c36zinbggzks X-Rspamd-Queue-Id: 59A50C00B5 X-Rspamd-Server: rspam11 X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=Sj3XbwYT; spf=pass (imf28.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-HE-Tag: 1655752471-627587 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 20-06-22 12:54:56, Julia Lawall wrote: > > > On Mon, 20 Jun 2022, Michal Hocko wrote: > > > On Sat 18-06-22 11:25:43, Charan Teja Kalla wrote: > > > Hello Andrew, > > > > > > On 6/18/2022 4:34 AM, kernel test robot wrote: > > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > > > > head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18 > > > > commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise > > > > date: 3 months ago > > > > compiler: mips-linux-gcc (GCC) 11.3.0 > > > > reproduce (cppcheck warning): > > > > # apt-get install cppcheck > > > > git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3 > > > > cppcheck --quiet --enable=style,performance,portability --template=gcc FILE > > > > > > > > If you fix the issue, kindly add following tag where applicable > > > > Reported-by: kernel test robot > > > > > > > > > > > > cppcheck warnings: (new ones prefixed by >>) > > > >>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment] > > > > ret = (total_len - iov_iter_count(&iter)) ? : ret; > > > > > > Other way to avoid this warning is by creating another local variable > > > that holds the total bytes processed. Having another local variable to > > > get rid off some compilation warning doesn't seem proper to me. So, > > > leaving this warning unless you ask me to fix this. > > > > Is this a new warning? I do not see it supported by my gcc 10.x. Do we > > cppcheck is a static analysis tool. It looks like it doesn't have a > proper understanding of ?: Ohh, thanks for the clarification! I thought this was a gcc feature. Then I would suggest to report a bug report against the static checker rather than making any changes to the kernel to workaround it. -- Michal Hocko SUSE Labs