[drm-tip:drm-tip 1291/1307] drivers/dma-buf/st-dma-resv.c:295:7: warning: variable 'i' is used uninitialized whenever 'if' condition is true

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

 



tree:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
head:   6eff63a9b932a4aa1e1f6e521cd919aaf57c058f
commit: 1d51775cd3f51899ce85afab686c7f641ff32d4e [1291/1307] dma-buf: add dma_resv selftest v4
config: arm-buildonly-randconfig-r006-20211025 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project a461fa64bb37cffd73f683c74f6b0780379fc2ca)
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
        git remote add drm-tip git://anongit.freedesktop.org/drm/drm-tip
        git fetch --no-tags drm-tip drm-tip
        git checkout 1d51775cd3f51899ce85afab686c7f641ff32d4e
        # 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@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/dma-buf/st-dma-resv.c:295:7: warning: variable 'i' is used uninitialized whenever 'if' condition is true [-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: warning: variable 'i' is used uninitialized whenever 'if' condition is true [-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 warnings 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]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux