All of lore.kernel.org
 help / color / mirror / Atom feed
* [dhowells-fs:netfs-crypt 49/49] fs/netfs/direct_write.c:128:7: warning: variable 'fpos2' is used uninitialized whenever 'if' condition is true
@ 2026-09-04 22:51 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-09-04 22:51 UTC (permalink / raw)
  To: David Howells; +Cc: oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git netfs-crypt
head:   cd7c017395defe44d80f4fb480dfec5e3772ea53
commit: cd7c017395defe44d80f4fb480dfec5e3772ea53 [49/49] netfs: Support encryption on unbuffered/DIO write
config: x86_64-allmodconfig (https://download.01.org/0day-ci/archive/20260905/202609050006.JGpiRJKU-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260905/202609050006.JGpiRJKU-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/202609050006.JGpiRJKU-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> fs/netfs/direct_write.c:128:7: warning: variable 'fpos2' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     128 |                 if (before && part <= 2 * PAGE_SIZE) {
         |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/netfs/direct_write.c:171:53: note: uninitialized use occurs here
     171 |         ret = netfs_rmw_read(wreq, before ?: after, fpos1, fpos2);
         |                                                            ^~~~~
   fs/netfs/direct_write.c:128:3: note: remove the 'if' if its condition is always false
     128 |                 if (before && part <= 2 * PAGE_SIZE) {
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     129 |                         struct bvecq *bq;
         |                         ~~~~~~~~~~~~~~~~~
     130 |                         size_t page0 = PAGE_SIZE - before->bv[0].bv_offset;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     131 |                         int slot;
         |                         ~~~~~~~~~
     132 | 
     133 |                         if (part <= page0) {
         |                         ~~~~~~~~~~~~~~~~~~~~
     134 |                                 before->bv[0].bv_len = part;
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     135 |                                 bvecq_filled_to(before, 1);
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
     136 |                                 goto do_it;
         |                                 ~~~~~~~~~~~
     137 |                         }
         |                         ~
     138 | 
     139 |                         bq = wreq->encrypt_cursor.bvecq;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     140 |                         slot = wreq->encrypt_cursor.slot + 1;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     141 |                         if (slot > bq->nr_slots) {
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~
     142 |                                 bq = bq->next;
         |                                 ~~~~~~~~~~~~~~
     143 |                                 slot = 0;
         |                                 ~~~~~~~~~
>> fs/netfs/direct_write.c:125:6: warning: variable 'fpos2' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     125 |         if (to == end && subreq->start + subreq->len < to) {
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/netfs/direct_write.c:171:53: note: uninitialized use occurs here
     171 |         ret = netfs_rmw_read(wreq, before ?: after, fpos1, fpos2);
         |                                                            ^~~~~
   fs/netfs/direct_write.c:125:2: note: remove the 'if' if its condition is always true
     125 |         if (to == end && subreq->start + subreq->len < to) {
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/netfs/direct_write.c:125:6: warning: variable 'fpos2' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
     125 |         if (to == end && subreq->start + subreq->len < to) {
         |             ^~~~~~~~~
   fs/netfs/direct_write.c:171:53: note: uninitialized use occurs here
     171 |         ret = netfs_rmw_read(wreq, before ?: after, fpos1, fpos2);
         |                                                            ^~~~~
   fs/netfs/direct_write.c:125:6: note: remove the '&&' if its condition is always true
     125 |         if (to == end && subreq->start + subreq->len < to) {
         |             ^~~~~~~~~~~~
   fs/netfs/direct_write.c:103:21: note: initialize the variable 'fpos2' to silence this warning
     103 |         uoff_t fpos1, fpos2;
         |                            ^
         |                             = 0
>> fs/netfs/direct_write.c:566:22: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
     566 |                 stream->buffered = ret;
         |                                    ^~~
   fs/netfs/direct_write.c:478:13: note: initialize the variable 'ret' to silence this warning
     478 |         ssize_t ret, n;
         |                    ^
         |                     = 0
   4 warnings generated.


vim +128 fs/netfs/direct_write.c

    93	
    94	/*
    95	 * Read gaps at either end of the bounce buffer that need to be filled for an
    96	 * RMW cycle.
    97	 */
    98	static ssize_t netfs_unbuffered_rmw(struct netfs_io_request *wreq,
    99					    struct netfs_io_subrequest *subreq,
   100					    uoff_t to, uoff_t end)
   101	{
   102		struct bvecq *before = NULL, *after = NULL;
   103		uoff_t fpos1, fpos2;
   104		size_t bsize = wreq->crypto_bsize;
   105		int ret;
   106	
   107		_enter("%llx,%llx", to, end);
   108	
   109		/* Build a buffer chain to cover the gaps.  If we have two gaps, they
   110		 * must be discontiguous and so we will need two separate bvecqs for
   111		 * that; however, if the entire write spans at most two pages, just do
   112		 * one read for both gaps plus the middle.
   113		 */
   114		if (subreq->start < wreq->start) {
   115			before = bvecq_alloc_one(2, wreq->gfp, false);
   116			if (!before)
   117				return -ENOMEM;
   118			fpos1 = subreq->start;
   119			before->bv[0] = wreq->encrypt_cursor.bvecq->bv[wreq->encrypt_cursor.slot];
   120			before->bv[0].bv_offset += wreq->encrypt_cursor.offset;
   121			before->bv[0].bv_len = bsize;
   122			bvecq_filled_to(before, 1);
   123		}
   124	
 > 125		if (to == end && subreq->start + subreq->len < to) {
   126			size_t part = end - subreq->start;
   127	
 > 128			if (before && part <= 2 * PAGE_SIZE) {
   129				struct bvecq *bq;
   130				size_t page0 = PAGE_SIZE - before->bv[0].bv_offset;
   131				int slot;
   132	
   133				if (part <= page0) {
   134					before->bv[0].bv_len = part;
   135					bvecq_filled_to(before, 1);
   136					goto do_it;
   137				}
   138	
   139				bq = wreq->encrypt_cursor.bvecq;
   140				slot = wreq->encrypt_cursor.slot + 1;
   141				if (slot > bq->nr_slots) {
   142					bq = bq->next;
   143					slot = 0;
   144				}
   145	
   146				before->bv[0].bv_len = page0;
   147				before->bv[1] = bq->bv[slot];
   148				before->bv[1].bv_len = part - page0;
   149				bvecq_filled_to(before, 2);
   150				goto do_it;
   151			}
   152	
   153			after = bvecq_alloc_one(1, wreq->gfp, false);
   154			if (!after) {
   155				ret = -ENOMEM;
   156				goto out;
   157			}
   158			fpos2 = to - bsize;
   159			after->bv[0] = wreq->bounce_alloc.bvecq->bv[wreq->bounce_alloc.slot];
   160			after->bv[0].bv_offset = to & (PAGE_SIZE - 1);
   161			after->bv[0].bv_len = bsize;
   162			bvecq_filled_to(after, 1);
   163		}
   164	
   165		if (before && after) {
   166			before->next = after;
   167			after->prev = before;
   168		}
   169	
   170	do_it:
   171		ret = netfs_rmw_read(wreq, before ?: after, fpos1, fpos2);
   172	
   173	out:
   174		bvecq_put(before ?: after);
   175		return ret;
   176	}
   177	

--
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:[~2026-09-04 22:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 22:51 [dhowells-fs:netfs-crypt 49/49] fs/netfs/direct_write.c:128:7: warning: variable 'fpos2' 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.