linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Philip Li <philip.li@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kernel test robot <lkp@intel.com>,
	David Finkel <davidf@vimeo.com>, <oe-kbuild-all@lists.linux.dev>,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [akpm-mm:mm-unstable 36/78] test_memcontrol.c:201:6: warning: variable 'fd4_closed' is used uninitialized whenever 'if' condition is true
Date: Mon, 29 Jul 2024 10:20:47 +0800	[thread overview]
Message-ID: <Zqb8f4ldSvBgHd2h@rli9-mobl> (raw)
In-Reply-To: <20240728131824.51628ab73f6318fe62e85742@linux-foundation.org>

On Sun, Jul 28, 2024 at 01:18:24PM -0700, Andrew Morton wrote:
> On Sun, 28 Jul 2024 11:58:47 +0800 kernel test robot <lkp@intel.com> wrote:
> 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
> > head:   b39b3892d20a337489c55806f91af581474f3943
> > commit: f2db5cca8182337f4ad485ebfd532b1a2d1c223a [36/78] mm, memcg: cg2 memory{.swap,}.peak write tests
> > :::::: branch date: 2 days ago
> > :::::: commit date: 3 days ago
> > compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240727/202407272301.bBC2CidR-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/r/202407272301.bBC2CidR-lkp@intel.com/
> > 
> > All warnings (new ones prefixed by >>):
> > 
> > >> test_memcontrol.c:201:6: warning: variable 'fd4_closed' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> 
> um,
> 
> 	bool fd2_closed = false, fd3_closed = false, fd4_closed = false;
> 
> fd4_closed cannot possibly be used uninitialized?

One possible flow is early peak_fd fails to open and go to cleanup, then
in cleanup side, the variable like fd4_closed is directly used.

+       if (peak_fd == -1)
+               goto cleanup;
+
+       bool fd2_closed = false, fd3_closed = false, fd4_closed = false;
+       int peak_fd2 = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC);
+
 ...

 cleanup:
+       close(peak_fd);
+       if (!fd2_closed)
+               close(peak_fd2);
+       if (!fd3_closed)
+               close(peak_fd3);
+       if (!fd4_closed)
+               close(peak_fd4);

> 


  reply	other threads:[~2024-07-29  2:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-28  3:58 kernel test robot
2024-07-28 20:18 ` Andrew Morton
2024-07-29  2:20   ` Philip Li [this message]
2024-07-29 13:45     ` David Finkel

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=Zqb8f4ldSvBgHd2h@rli9-mobl \
    --to=philip.li@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=davidf@vimeo.com \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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