All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: David Howells <dhowells@redhat.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [dhowells-fs:netfs-crypt 49/49] fs/netfs/direct_write.c:128:7: warning: variable 'fpos2' is used uninitialized whenever 'if' condition is true
Date: Sat, 05 Sep 2026 00:51:49 +0200	[thread overview]
Message-ID: <202609050006.JGpiRJKU-lkp@intel.com> (raw)

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

                 reply	other threads:[~2026-09-04 22:52 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=202609050006.JGpiRJKU-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=dhowells@redhat.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 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.