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 644B6C433EF for ; Mon, 20 Jun 2022 16:29:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 983656B0072; Mon, 20 Jun 2022 12:29:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90CFF8E0002; Mon, 20 Jun 2022 12:29:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AEB16B0075; Mon, 20 Jun 2022 12:29:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 670516B0072 for ; Mon, 20 Jun 2022 12:29:41 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3E449320B2 for ; Mon, 20 Jun 2022 16:29:41 +0000 (UTC) X-FDA: 79599150162.06.1A480E4 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf19.hostedemail.com (Postfix) with ESMTP id AE0F11A00A2 for ; Mon, 20 Jun 2022 16:29:40 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4B4A61F74D; Mon, 20 Jun 2022 16:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655742578; 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=2md7ifxeCy3ar4+fRCCm0Z7DlFfpGvnA2qgiu2UJkUE=; b=YQvRNX6dvhgZKRjAxTBToMujsPekyvCYfwq1UZq/SLX6YzAYT/NTOm/gllMyWzg+iAqPfV d0ECKD0X2JriVbcSOU3H6KyKecdXAd4OY3bIGwerYWtp+GNS3mfZGLczL989T3RmW8nZon dmRwExPsEAqr8iy6icWmtpHu525NOW4= 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 868D42C141; Mon, 20 Jun 2022 16:29:37 +0000 (UTC) Date: Mon, 20 Jun 2022 18:29:36 +0200 From: Michal Hocko To: Charan Teja Kalla Cc: kernel test robot , Minchan Kim , kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Andrew Morton , Linux Memory Management List Subject: 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: <5ec7b561-551b-f02a-9b7b-65d05ccdabbc@quicinc.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655742580; a=rsa-sha256; cv=none; b=jvK1IP8vc8o6M50l0mkrfKUvCgb5J+4KTZnM5K/PZkOGyIlKhFULaUs+pUPaTgUdOtt5TY PcIVYkfgZQxcQlktouw3jYpXMtXZk6CrHsuUoY91+I6f/3pKDEf3kTL9k8LI5NA8qPjaf6 YlyaGwQ95HfoeCSfVV3wPsI6fnqB6Cg= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=YQvRNX6d; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655742580; 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=2md7ifxeCy3ar4+fRCCm0Z7DlFfpGvnA2qgiu2UJkUE=; b=KCUDjKQ82S36s3C0oq5ZYLWjXggyENG1pg4/1vK2bbusI7GZU68SIFbldbRtP70TAUVSkh 6fsi2o+4ez/QHmFbMH4jsN7v6GytjdQ8ETleEHPmO0UkSgIemX0iQUj07AYGWW/wWzLBGq Gh6TTxaBesF8111kt8TCX+vAYaRfs14= Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=YQvRNX6d; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-Stat-Signature: cwepewk55o9jkmodam56izs3xb7wh4uh X-Rspamd-Queue-Id: AE0F11A00A2 X-Rspamd-Server: rspam08 X-HE-Tag: 1655742580-752931 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 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 plan to have it enabled by default? I do not see anything wrong with the above code and I think this is not an unusual pattern in the kernel. While you could go with if (rotal_len - iov_iter_count(&iter)) ret = rotal_len - iov_iter_count(&iter); or do the same with a temporary variable but I am not really sure this would add to the readability much. -- Michal Hocko SUSE Labs