Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3054815iog; Mon, 20 Jun 2022 10:11:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vTGKy5z+2P/E1fvDE4xb5KhNFolIza+/p4pl8jFP8Y+FxbSeYweahDK/qboxg1BzDhUKzs X-Received: by 2002:a17:906:72d1:b0:712:782:6fb1 with SMTP id m17-20020a17090672d100b0071207826fb1mr22167226ejl.217.1655745106190; Mon, 20 Jun 2022 10:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655745106; cv=none; d=google.com; s=arc-20160816; b=Iu/mNblG6TnzO+UCDnD21lWbp+Pcnq9SJiPRKDZTPwOIBrXz+Hoi3mYDGlyD7hejOA 5HpDS5UfzJH4Xx9iZbrM44L5CptEYOS8s8s12W1ofaAc5YgmONp1ubWD5huHUrFb4fy0 8HWZS5YzvYqxGp7+XGz9kyqDHmX/Hxg7hSaCtghrYnM1IhijYcaAbUISciPiarrIgz9t 5oNeey807MNYa3LXnCneIte5RRZ1n9dgXW8IgD9kgot/AA3DWMl+EJUUK2lV54oHNmtJ ID36xcWMyNXLfpCsquxC/DGs/hiArblX1rA/U13aPPpwIHd3/vGT7BehcGIsmipRSSv3 4v5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2md7ifxeCy3ar4+fRCCm0Z7DlFfpGvnA2qgiu2UJkUE=; b=rT4nrZF2Ws79G6XMRV/0BJCWBsPONXSpe6YZVOf3HWZBu5TWVhzrySV1+qIrJBbp7O QR8UpYze6f0oppYuv3qYdqZ5PTk+Huosjzdy+0nuSOeKjbOslXfBoDZwGbUIOrGoG38n Pvcw8CwS5DX0IXX9DO+mg3U94KnAJ9nByACwz7+UxW8LRQTkCnh2MQpY7+f64PBZR/x4 A1fXbvDSTBYqTfENhy696A280HXfKk8eSKu1h5BJXqT2TzexbG0zT/PgjGlfuox2f5dy V8AgV08SWf5K0hnYSNPmEj0nN33Nhk6K3jhYyJ+iCTMqD2kU3Wyu2LrGJ/9g/OJfI2xB sMoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=YQvRNX6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g24-20020a056402321800b004357cb69446si4754618eda.179.2022.06.20.10.11.18; Mon, 20 Jun 2022 10:11:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=YQvRNX6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242197AbiFTQ3m (ORCPT + 99 others); Mon, 20 Jun 2022 12:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234213AbiFTQ3k (ORCPT ); Mon, 20 Jun 2022 12:29:40 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C152DFD1 for ; Mon, 20 Jun 2022 09:29:39 -0700 (PDT) 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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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