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 558CDC433EF for ; Mon, 20 Jun 2022 16:55:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A521F6B0071; Mon, 20 Jun 2022 12:55:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A00A76B0073; Mon, 20 Jun 2022 12:55:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C84A8E0001; Mon, 20 Jun 2022 12:55:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7C6656B0071 for ; Mon, 20 Jun 2022 12:55:07 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 47E22334B1 for ; Mon, 20 Jun 2022 16:55:07 +0000 (UTC) X-FDA: 79599214254.27.B22BEF7 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by imf23.hostedemail.com (Postfix) with ESMTP id 0E60C14009E for ; Mon, 20 Jun 2022 16:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=80UMITqfcEXbQBuxCEFv3WvM8vMQi18p2VPQJD28/NU=; b=WplHZSV4v5Cb0PupcCAvLTVl7rdhbOpIS6h6wmjsTuLVWqUKIpFjJXTH goJOfa+jBX6rEgM177rcNmCn5TF5U3v1oNcu4YWwQX8qHrzWJSPI5GM7U IsmNhZLRciRMwuchLMDYSwO8hR+m5i0zewHsqERY+sC7raeCWNdnlHK/t U=; X-IronPort-AV: E=Sophos;i="5.92,207,1650924000"; d="scan'208";a="17310869" Received: from 71-51-190-12.chvl.centurylink.net (HELO hadrien) ([71.51.190.12]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2022 18:55:02 +0200 Date: Mon, 20 Jun 2022 12:54:56 -0400 (EDT) From: Julia Lawall X-X-Sender: julia@hadrien To: Michal Hocko 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] In-Reply-To: Message-ID: References: <202206180617.UzO7ymnD-lkp@intel.com> <5ec7b561-551b-f02a-9b7b-65d05ccdabbc@quicinc.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655744106; a=rsa-sha256; cv=none; b=NZ8/70FatskJKryR337dvd5htF9tUiua1bikxDOXUsTAesFORAvIrhLVY+bvaeoJYg6zvp /bHZ6jbxe5cBod7En9UA/6Htae0Bkxxwp8p+gR1NGE2XwRqenbfq5cM43991fc3YQFSgI5 FB3LZcahg5T4Bk518MNoPxky6M+kLBY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=inria.fr header.s=dc header.b=WplHZSV4; dmarc=pass (policy=none) header.from=inria.fr; spf=pass (imf23.hostedemail.com: domain of julia.lawall@inria.fr designates 192.134.164.104 as permitted sender) smtp.mailfrom=julia.lawall@inria.fr ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655744106; 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=80UMITqfcEXbQBuxCEFv3WvM8vMQi18p2VPQJD28/NU=; b=6wCJqoYijO/oGKhkdIiUMHmV7DpEg7eqCN626Tam4ya6miCH5JKmCz6gb442rGmQ2dIpNC 3TK7mr1J+kG8EDTC0rq5HEer3THkOvVJwB5o6HtBTzVeLQO3yE99BO7ujeMj8xhWWLQg0H EnDc99iPKfKJgoMZAnmd0XGwHjwdZGo= Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=inria.fr header.s=dc header.b=WplHZSV4; dmarc=pass (policy=none) header.from=inria.fr; spf=pass (imf23.hostedemail.com: domain of julia.lawall@inria.fr designates 192.134.164.104 as permitted sender) smtp.mailfrom=julia.lawall@inria.fr X-Rspam-User: X-Stat-Signature: kgcm1qyb7kzdi715gndjd6qrrrs5yxew X-Rspamd-Queue-Id: 0E60C14009E X-Rspamd-Server: rspam08 X-HE-Tag: 1655744105-283496 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 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 ?: julia > 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 > _______________________________________________ > kbuild-all mailing list -- kbuild-all@lists.01.org > To unsubscribe send an email to kbuild-all-leave@lists.01.org >