linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Michal Hocko <mhocko@suse.com>
Cc: Charan Teja Kalla <quic_charante@quicinc.com>,
	 kernel test robot <lkp@intel.com>,
	Minchan Kim <minchan@kernel.org>,
	 kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [kbuild-all] Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
Date: Mon, 20 Jun 2022 12:54:56 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2206201253480.2243@hadrien> (raw)
In-Reply-To: <YrCgcEGKxjN7mNu9@dhcp22.suse.cz>



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 <lkp@intel.com>
> > >
> > >
> > > 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
>


  reply	other threads:[~2022-06-20 16:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 23:04 kernel test robot
2022-06-18  5:55 ` Charan Teja Kalla
2022-06-20 16:29   ` Michal Hocko
2022-06-20 16:54     ` Julia Lawall [this message]
2022-06-20 19:14       ` [kbuild-all] " Michal Hocko
2022-06-22  2:37         ` Chen, Rong A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2206201253480.2243@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=akpm@linux-foundation.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=quic_charante@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox