[linux-next:master 10147/11937] drivers/dma-buf/st-dma-resv.c:295:7: error: variable 'i' is used uninitialized whenever 'if' condition is true

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   ae5179317e794160e471db0e122c6ac811a97235
commit: 1d51775cd3f51899ce85afab686c7f641ff32d4e [10147/11937] dma-buf: add dma_resv selftest v4
config: i386-buildonly-randconfig-r005-20211027 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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/next/linux-next.git/commit/?id=1d51775cd3f51899ce85afab686c7f641ff32d4e
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout 1d51775cd3f51899ce85afab686c7f641ff32d4e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386 

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

All errors (new ones prefixed by >>):

>> drivers/dma-buf/st-dma-resv.c:295:7: error: variable 'i' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
                   if (r) {
                       ^
   drivers/dma-buf/st-dma-resv.c:336:9: note: uninitialized use occurs here
           while (i--)
                  ^
   drivers/dma-buf/st-dma-resv.c:295:3: note: remove the 'if' if its condition is always false
                   if (r) {
                   ^~~~~~~~
   drivers/dma-buf/st-dma-resv.c:288:6: error: variable 'i' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
           if (r) {
               ^
   drivers/dma-buf/st-dma-resv.c:336:9: note: uninitialized use occurs here
           while (i--)
                  ^
   drivers/dma-buf/st-dma-resv.c:288:2: note: remove the 'if' if its condition is always false
           if (r) {
           ^~~~~~~~
   drivers/dma-buf/st-dma-resv.c:280:10: note: initialize the variable 'i' to silence this warning
           int r, i;
                   ^
                    = 0
   2 errors generated.


vim +295 drivers/dma-buf/st-dma-resv.c

   275	
   276	static int test_get_fences(void *arg, bool shared)
   277	{
   278		struct dma_fence *f, *excl = NULL, **fences = NULL;
   279		struct dma_resv resv;
   280		int r, i;
   281	
   282		f = alloc_fence();
   283		if (!f)
   284			return -ENOMEM;
   285	
   286		dma_resv_init(&resv);
   287		r = dma_resv_lock(&resv, NULL);
   288		if (r) {
   289			pr_err("Resv locking failed\n");
   290			goto err_free;
   291		}
   292	
   293		if (shared) {
   294			r = dma_resv_reserve_shared(&resv, 1);
 > 295			if (r) {
   296				pr_err("Resv shared slot allocation failed\n");
   297				dma_resv_unlock(&resv);
   298				goto err_free;
   299			}
   300	
   301			dma_resv_add_shared_fence(&resv, f);
   302		} else {
   303			dma_resv_add_excl_fence(&resv, f);
   304		}
   305		dma_resv_unlock(&resv);
   306	
   307		r = dma_resv_get_fences(&resv, &excl, &i, &fences);
   308		if (r) {
   309			pr_err("get_fences failed\n");
   310			goto err_free;
   311		}
   312	
   313		if (shared) {
   314			if (excl != NULL) {
   315				pr_err("get_fences returned unexpected excl fence\n");
   316				goto err_free;
   317			}
   318			if (i != 1 || fences[0] != f) {
   319				pr_err("get_fences returned unexpected shared fence\n");
   320				goto err_free;
   321			}
   322		} else {
   323			if (excl != f) {
   324				pr_err("get_fences returned unexpected excl fence\n");
   325				goto err_free;
   326			}
   327			if (i != 0) {
   328				pr_err("get_fences returned unexpected shared fence\n");
   329				goto err_free;
   330			}
   331		}
   332	
   333		dma_fence_signal(f);
   334	err_free:
   335		dma_fence_put(excl);
   336		while (i--)
   337			dma_fence_put(fences[i]);
   338		kfree(fences);
   339		dma_resv_fini(&resv);
   340		dma_fence_put(f);
   341		return r;
   342	}
   343	

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux