Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [dhowells-fs:netfs-writeback 17/17] fs/netfs/buffered_read.c:276:7: warning: variable 'slice' is used uninitialized whenever 'if' condition is false
@ 2024-06-21  4:27 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-06-21  4:27 UTC (permalink / raw)
  To: David Howells; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git netfs-writeback
head:   d75f8ece3c49fa2ab1299cdabfc879952702a19a
commit: d75f8ece3c49fa2ab1299cdabfc879952702a19a [17/17] netfs: Speed up buffered reading
config: i386-buildonly-randconfig-003-20240621 (https://download.01.org/0day-ci/archive/20240621/202406211226.JKZxYvs6-lkp@intel.com/config)
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/20240621/202406211226.JKZxYvs6-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/202406211226.JKZxYvs6-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> fs/netfs/buffered_read.c:276:7: warning: variable 'slice' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     276 |                 if (source == NETFS_INVALID_READ)
         |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/netfs/buffered_read.c:280:11: note: uninitialized use occurs here
     280 |                 size -= slice;
         |                         ^~~~~
   fs/netfs/buffered_read.c:276:3: note: remove the 'if' if its condition is always true
     276 |                 if (source == NETFS_INVALID_READ)
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     277 |                         break;
   fs/netfs/buffered_read.c:222:16: note: initialize the variable 'slice' to silence this warning
     222 |                 ssize_t slice;
         |                              ^
         |                               = 0
   fs/netfs/buffered_read.c:23:13: warning: unused function 'netfs_rreq_expand' [-Wunused-function]
      23 | static void netfs_rreq_expand(struct netfs_io_request *rreq,
         |             ^~~~~~~~~~~~~~~~~
   2 warnings generated.


vim +276 fs/netfs/buffered_read.c

   206	
   207	/*
   208	 * Perform a read to the pagecache from a series of sources of different types,
   209	 * slicing up the region to be read according to available cache blocks and
   210	 * network rsize.
   211	 */
   212	static int netfs_read_to_pagecache(struct netfs_io_request *rreq)
   213	{
   214		struct netfs_inode *ictx = netfs_inode(rreq->inode);
   215		unsigned long long start = rreq->start;
   216		ssize_t size = rreq->len;
   217	
   218		/* Chop the readahead request up into subrequests. */
   219		do {
   220			struct netfs_io_subrequest *subreq;
   221			enum netfs_io_source source = NETFS_DOWNLOAD_FROM_SERVER;
   222			ssize_t slice;
   223	
   224			subreq = netfs_alloc_subrequest(rreq);
   225			if (!subreq)
   226				return -ENOMEM;
   227	
   228			subreq->source	= NETFS_DOWNLOAD_FROM_SERVER;
   229			subreq->start	= start;
   230			subreq->len	= size;
   231	
   232			spin_lock(&rreq->lock);
   233			list_add_tail(&subreq->rreq_link, &rreq->subrequests);
   234			subreq->prev_donated = rreq->prev_donated;
   235			rreq->prev_donated = 0;
   236			trace_netfs_sreq(subreq, netfs_sreq_trace_added);
   237			spin_unlock(&rreq->lock);
   238	
   239			source = netfs_cache_prepare_read(rreq, subreq, rreq->i_size);
   240			if (source == NETFS_DOWNLOAD_FROM_SERVER) {
   241				if (subreq->start >= ictx->zero_point) {
   242					subreq->source = source = NETFS_FILL_WITH_ZEROES;
   243					goto fill_with_zeroes;
   244				}
   245	
   246				if (subreq->len > ictx->zero_point - subreq->start)
   247					subreq->len = ictx->zero_point - subreq->start;
   248				if (subreq->len > rreq->i_size - subreq->start)
   249					subreq->len = rreq->i_size - subreq->start;
   250	
   251				netfs_stat(&netfs_n_rh_download);
   252				slice = rreq->netfs_ops->issue_read(subreq);
   253				if (slice <= 0)
   254					return slice;
   255				goto done;
   256			}
   257	
   258		fill_with_zeroes:
   259			if (source == NETFS_FILL_WITH_ZEROES) {
   260				subreq->source = NETFS_FILL_WITH_ZEROES;
   261				trace_netfs_sreq(subreq, netfs_sreq_trace_submit);
   262				netfs_stat(&netfs_n_rh_zero);
   263				slice = subreq->len;
   264				subreq->transferred = slice;
   265				__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
   266				netfs_read_subreq_progress(subreq, 0, false);
   267				goto done;
   268			}
   269	
   270			if (source == NETFS_READ_FROM_CACHE) {
   271				trace_netfs_sreq(subreq, netfs_sreq_trace_submit);
   272				slice = netfs_read_cache_to_pagecache(rreq, subreq);
   273				goto done;
   274			}
   275	
 > 276			if (source == NETFS_INVALID_READ)
   277				break;
   278	
   279		done:
   280			size -= slice;
   281			start += slice;
   282			cond_resched();
   283		} while (size > 0);
   284	
   285		return 0;
   286	}
   287	

-- 
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:[~2024-06-21  4:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-21  4:27 [dhowells-fs:netfs-writeback 17/17] fs/netfs/buffered_read.c:276:7: warning: variable 'slice' is used uninitialized whenever 'if' condition is false kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox