[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YrCgcEGKxjN7mNu9@dhcp22.suse.cz>
Date: Mon, 20 Jun 2022 18:29:36 +0200
From: Michal Hocko <mhocko@...e.com>
To: Charan Teja Kalla <quic_charante@...cinc.com>
Cc: kernel test robot <lkp@...el.com>,
Minchan Kim <minchan@...nel.org>, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Memory Management List <linux-mm@...ck.org>
Subject: Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to
itself. [selfAssignment]
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@...el.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
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
Powered by blists - more mailing lists