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 92478C433EF for ; Mon, 20 Jun 2022 19:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245422AbiFTTOr (ORCPT ); Mon, 20 Jun 2022 15:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243729AbiFTTOd (ORCPT ); Mon, 20 Jun 2022 15:14:33 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5509118E24 for ; Mon, 20 Jun 2022 12:14:31 -0700 (PDT) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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