From: kernel test robot <lkp@intel.com>
To: Christoph Hellwig <hch@lst.de>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [hch-misc:block-new-helpers 18/18] kernel/power/swap.c:381:6: warning: variable 'src' is used uninitialized whenever 'if' condition is true
Date: Tue, 22 Apr 2025 03:31:01 +0800 [thread overview]
Message-ID: <202504220332.MiiqLjIT-lkp@intel.com> (raw)
tree: git://git.infradead.org/users/hch/misc.git block-new-helpers
head: 280d8b7173282de4cf4857624def142ed24fad63
commit: 280d8b7173282de4cf4857624def142ed24fad63 [18/18] PM: hibernate: split and simplify hib_submit_io
config: i386-buildonly-randconfig-001-20250422 (https://download.01.org/0day-ci/archive/20250422/202504220332.MiiqLjIT-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250422/202504220332.MiiqLjIT-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/oe-kbuild-all/202504220332.MiiqLjIT-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/power/swap.c:381:6: warning: variable 'src' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
381 | if (!hb)
| ^~~
kernel/power/swap.c:397:61: note: uninitialized use occurs here
397 | return hib_submit_io_sync(REQ_OP_WRITE | REQ_SYNC, offset, src);
| ^~~
kernel/power/swap.c:381:2: note: remove the 'if' if its condition is always false
381 | if (!hb)
| ^~~~~~~~
382 | goto sync_io;
| ~~~~~~~~~~~~
kernel/power/swap.c:375:11: note: initialize the variable 'src' to silence this warning
375 | void *src;
| ^
| = NULL
1 warning generated.
vim +381 kernel/power/swap.c
364
365 /**
366 * write_page - Write one page to given swap location.
367 * @buf: Address we're writing.
368 * @offset: Offset of the swap page we're writing to.
369 * @hb: bio completion batch
370 */
371
372 static int write_page(void *buf, sector_t offset, struct hib_bio_batch *hb)
373 {
374 gfp_t gfp = GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY;
375 void *src;
376 int ret;
377
378 if (!offset)
379 return -ENOSPC;
380
> 381 if (!hb)
382 goto sync_io;
383
384 src = (void *)__get_free_page(gfp);
385 if (!src) {
386 ret = hib_wait_io(hb); /* Free pages */
387 if (ret)
388 return ret;
389 src = (void *)__get_free_page(gfp);
390 if (WARN_ON_ONCE(!src))
391 goto sync_io;
392 }
393
394 copy_page(src, buf);
395 return hib_submit_io_async(REQ_OP_WRITE | REQ_SYNC, offset, src, hb);
396 sync_io:
397 return hib_submit_io_sync(REQ_OP_WRITE | REQ_SYNC, offset, src);
398 }
399
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2025-04-21 19:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202504220332.MiiqLjIT-lkp@intel.com \
--to=lkp@intel.com \
--cc=hch@lst.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.