linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: David Howells <dhowells@redhat.com>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org
Subject: [dhowells-fs:fscache-rewrite-indexing 76/77] fs/cachefiles/io.c:480:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false
Date: Sun, 7 Nov 2021 04:10:57 +0800	[thread overview]
Message-ID: <202111070451.bsfAyznx-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5015 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-rewrite-indexing
head:   77d7cb0fca08e72544d242d6897dede22de6bc20
commit: 0790bec522903af7ee7281721e037bee2e8c6284 [76/77] cachefiles: Add error injection support
config: arm-buildonly-randconfig-r005-20211019 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d245f2e8597bfb52c34810a328d42b990e4af1a4)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?id=0790bec522903af7ee7281721e037bee2e8c6284
        git remote add dhowells-fs https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
        git fetch --no-tags dhowells-fs fscache-rewrite-indexing
        git checkout 0790bec522903af7ee7281721e037bee2e8c6284
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> fs/cachefiles/io.c:480:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
           if (pos == 0)
               ^~~~~~~~
   fs/cachefiles/io.c:483:6: note: uninitialized use occurs here
           if (ret < 0) {
               ^~~
   fs/cachefiles/io.c:480:2: note: remove the 'if' if its condition is always true
           if (pos == 0)
           ^~~~~~~~~~~~~
   fs/cachefiles/io.c:433:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0
   1 error generated.


vim +480 fs/cachefiles/io.c

   420	
   421	/*
   422	 * Prepare for a write to occur.
   423	 */
   424	static int __cachefiles_prepare_write(struct netfs_cache_resources *cres,
   425					      loff_t *_start, size_t *_len, loff_t i_size,
   426					      bool no_space_allocated_yet)
   427	{
   428		struct cachefiles_object *object = cachefiles_cres_object(cres);
   429		struct cachefiles_cache *cache = object->volume->cache;
   430		struct file *file = cachefiles_cres_file(cres);
   431		loff_t start = *_start, pos;
   432		size_t len = *_len, down;
   433		int ret;
   434	
   435		/* Round to DIO size */
   436		down = start - round_down(start, PAGE_SIZE);
   437		*_start = start - down;
   438		*_len = round_up(down + len, PAGE_SIZE);
   439	
   440		/* We need to work out whether there's sufficient disk space to perform
   441		 * the write - but we can skip that check if we have space already
   442		 * allocated.
   443		 */
   444		if (no_space_allocated_yet)
   445			goto check_space;
   446	
   447		pos = cachefiles_inject_read_error();
   448		if (pos == 0)
   449			pos = vfs_llseek(file, *_start, SEEK_DATA);
   450		if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
   451			if (pos == -ENXIO)
   452				goto check_space; /* Unallocated tail */
   453			trace_cachefiles_io_error(object, file_inode(file), pos,
   454						  cachefiles_trace_seek_error);
   455			return pos;
   456		}
   457		if ((u64)pos >= (u64)*_start + *_len)
   458			goto check_space; /* Unallocated region */
   459	
   460		/* We have a block that's at least partially filled - if we're low on
   461		 * space, we need to see if it's fully allocated.  If it's not, we may
   462		 * want to cull it.
   463		 */
   464		if (cachefiles_has_space(cache, 0, *_len / PAGE_SIZE) == 0)
   465			return 0; /* Enough space to simply overwrite the whole block */
   466	
   467		pos = cachefiles_inject_read_error();
   468		if (pos == 0)
   469			pos = vfs_llseek(file, *_start, SEEK_HOLE);
   470		if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
   471			trace_cachefiles_io_error(object, file_inode(file), pos,
   472						  cachefiles_trace_seek_error);
   473			return pos;
   474		}
   475		if ((u64)pos >= (u64)*_start + *_len)
   476			return 0; /* Fully allocated */
   477	
   478		/* Partially allocated, but insufficient space: cull. */
   479		pos = cachefiles_inject_remove_error();
 > 480		if (pos == 0)
   481			ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
   482					    *_start, *_len);
   483		if (ret < 0) {
   484			trace_cachefiles_io_error(object, file_inode(file), ret,
   485						  cachefiles_trace_fallocate_error);
   486			cachefiles_io_error_obj(object,
   487						"CacheFiles: fallocate failed (%d)\n", ret);
   488			ret = -EIO;
   489		}
   490	
   491		return ret;
   492	
   493	check_space:
   494		return cachefiles_has_space(cache, 0, *_len / PAGE_SIZE);
   495	}
   496	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31547 bytes --]

                 reply	other threads:[~2021-11-06 20:11 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=202111070451.bsfAyznx-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=dhowells@redhat.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).