[viro-vfs:work.iov_iter_get_pages 21/33] lib/iov_iter.c:1392:24: warning: variable 'len' is uninitialized when used here

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.iov_iter_get_pages
head:   eaf51d32a6d0a79ce7096996fd432ebb03b725e1
commit: 380244e4bdf81bb2e69ed68827d9718d5bfc1bb4 [21/33] iov_iter: massage calling conventions for first_{iovec,bvec}_segment()
config: i386-randconfig-a002 (https://download.01.org/0day-ci/archive/20220618/202206181816.oFNEwB8K-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 91688716ba49942051dccdf7b9c4f81a7ec8feaf)
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
        # https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git/commit/?id=380244e4bdf81bb2e69ed68827d9718d5bfc1bb4
        git remote add viro-vfs https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git
        git fetch --no-tags viro-vfs work.iov_iter_get_pages
        git checkout 380244e4bdf81bb2e69ed68827d9718d5bfc1bb4
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> lib/iov_iter.c:1392:24: warning: variable 'len' is uninitialized when used here [-Wuninitialized]
                   return min_t(size_t, len, res * PAGE_SIZE - *start);
                                        ^~~
   include/linux/minmax.h:104:48: note: expanded from macro 'min_t'
   #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
                                                        ^
   include/linux/minmax.h:38:14: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                              ^
   include/linux/minmax.h:31:25: note: expanded from macro '__cmp_once'
                   typeof(x) unique_x = (x);               \
                                         ^
   lib/iov_iter.c:1361:12: note: initialize the variable 'len' to silence this warning
           size_t len;
                     ^
                      = 0
   1 warning generated.


vim +/len +1392 lib/iov_iter.c

  1356	
  1357	static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i,
  1358			   struct page ***pages, size_t maxsize,
  1359			   unsigned int maxpages, size_t *start)
  1360	{
  1361		size_t len;
  1362		int n, res;
  1363	
  1364		if (maxsize > i->count)
  1365			maxsize = i->count;
  1366		if (!maxsize)
  1367			return 0;
  1368		if (maxsize > LONG_MAX)
  1369			maxsize = LONG_MAX;
  1370	
  1371		if (likely(user_backed_iter(i))) {
  1372			unsigned int gup_flags = 0;
  1373			unsigned long addr;
  1374	
  1375			if (iov_iter_rw(i) != WRITE)
  1376				gup_flags |= FOLL_WRITE;
  1377			if (i->nofault)
  1378				gup_flags |= FOLL_NOFAULT;
  1379	
  1380			addr = first_iovec_segment(i, &maxsize, start);
  1381			n = DIV_ROUND_UP(maxsize + *start, PAGE_SIZE);
  1382			if (n > maxpages)
  1383				n = maxpages;
  1384			if (*pages) {
  1385				*pages = get_pages_array(n);
  1386				if (!*pages)
  1387					return -ENOMEM;
  1388			}
  1389			res = get_user_pages_fast(addr, n, gup_flags, *pages);
  1390			if (unlikely(res <= 0))
  1391				return res;
> 1392			return min_t(size_t, len, res * PAGE_SIZE - *start);
  1393		}
  1394		if (iov_iter_is_bvec(i)) {
  1395			struct page **p;
  1396			struct page *page;
  1397	
  1398			page = first_bvec_segment(i, &maxsize, start);
  1399			n = DIV_ROUND_UP(maxsize + *start, PAGE_SIZE);
  1400			if (n > maxpages)
  1401				n = maxpages;
  1402			p = *pages;
  1403			if (!p) {
  1404				*pages = p = get_pages_array(n);
  1405				if (!p)
  1406					return -ENOMEM;
  1407			}
  1408			for (int k = 0; k < n; k++)
  1409				get_page(*p++ = page++);
  1410			return min_t(size_t, maxsize, n * PAGE_SIZE - *start);
  1411		}
  1412		if (iov_iter_is_pipe(i))
  1413			return pipe_get_pages(i, pages, maxsize, maxpages, start);
  1414		if (iov_iter_is_xarray(i))
  1415			return iter_xarray_get_pages(i, pages, maxsize, maxpages,
  1416						     start);
  1417		return -EFAULT;
  1418	}
  1419	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux