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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80FAEC433EF for ; Mon, 20 Jun 2022 16:55:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236985AbiFTQzL (ORCPT ); Mon, 20 Jun 2022 12:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231773AbiFTQzI (ORCPT ); Mon, 20 Jun 2022 12:55:08 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BCC1193E0 for ; Mon, 20 Jun 2022 09:55:06 -0700 (PDT) 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=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >