* [hch-misc:block-new-helpers 18/18] kernel/power/swap.c:381:6: warning: variable 'src' is used uninitialized whenever 'if' condition is true
@ 2025-04-21 19:31 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-04-21 19:31 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: oe-kbuild-all
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-04-21 19:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 19:31 [hch-misc:block-new-helpers 18/18] kernel/power/swap.c:381:6: warning: variable 'src' is used uninitialized whenever 'if' condition is true kernel test robot
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.