[linux-next:master 329/2265] drivers/gpu/drm/tests/drm_buddy_test.c:431:7: warning: Local variable 'order' shadows outer variable [shadowVariable]

[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:   8755ae45a9e8ae883fa7f4eb0162830c55aacf14
commit: 932da861956ac425ba4e65f7696458f96d833883 [329/2265] drm: selftest: convert drm_buddy selftest to KUnit
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 932da861956ac425ba4e65f7696458f96d833883
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

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

cppcheck warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/tests/drm_buddy_test.c:431:7: warning: Local variable 'order' shadows outer variable [shadowVariable]
     int order, err;
         ^
   drivers/gpu/drm/tests/drm_buddy_test.c:410:7: note: Shadowed declaration
    int *order;
         ^
   drivers/gpu/drm/tests/drm_buddy_test.c:431:7: note: Shadow variable
     int order, err;
         ^

vim +/order +431 drivers/gpu/drm/tests/drm_buddy_test.c

   404	
   405	static void igt_buddy_alloc_smoke(struct kunit *test)
   406	{
   407		u64 mm_size, chunk_size, start = 0;
   408		unsigned long flags = 0;
   409		struct drm_buddy mm;
   410		int *order;
   411		int i;
   412	
   413		DRM_RND_STATE(prng, random_seed);
   414		IGT_TIMEOUT(end_time);
   415	
   416		igt_mm_config(&mm_size, &chunk_size);
   417	
   418		KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, chunk_size),
   419				       "buddy_init failed\n");
   420	
   421		order = drm_random_order(mm.max_order + 1, &prng);
   422		KUNIT_ASSERT_TRUE(test, order);
   423	
   424		for (i = 0; i <= mm.max_order; ++i) {
   425			struct drm_buddy_block *block;
   426			int max_order = order[i];
   427			bool timeout = false;
   428			LIST_HEAD(blocks);
   429			u64 total, size;
   430			LIST_HEAD(tmp);
 > 431			int order, err;
   432	
   433			KUNIT_ASSERT_FALSE_MSG(test, igt_check_mm(test, &mm),
   434					       "pre-mm check failed, abort\n");
   435	
   436			order = max_order;
   437			total = 0;
   438	
   439			do {
   440	retry:
   441				size = get_size(order, chunk_size);
   442				err = drm_buddy_alloc_blocks(&mm, start, mm_size, size, size, &tmp, flags);
   443				if (err) {
   444					if (err == -ENOMEM) {
   445						KUNIT_FAIL(test, "buddy_alloc hit -ENOMEM with order=%d\n",
   446							   order);
   447					} else {
   448						if (order--) {
   449							err = 0;
   450							goto retry;
   451						}
   452	
   453						KUNIT_FAIL(test, "buddy_alloc with order=%d failed\n",
   454							   order);
   455					}
   456	
   457					break;
   458				}
   459	
   460				block = list_first_entry_or_null(&tmp, struct drm_buddy_block, link);
   461				KUNIT_ASSERT_TRUE_MSG(test, block, "alloc_blocks has no blocks\n");
   462	
   463				list_move_tail(&block->link, &blocks);
   464				KUNIT_EXPECT_EQ_MSG(test, drm_buddy_block_order(block), order,
   465						    "buddy_alloc order mismatch\n");
   466	
   467				total += drm_buddy_block_size(&mm, block);
   468	
   469				if (__igt_timeout(end_time, NULL)) {
   470					timeout = true;
   471					break;
   472				}
   473			} while (total < mm.size);
   474	
   475			if (!err)
   476				err = igt_check_blocks(test, &mm, &blocks, total, false);
   477	
   478			drm_buddy_free_list(&mm, &blocks);
   479	
   480			if (!err) {
   481				KUNIT_EXPECT_FALSE_MSG(test, igt_check_mm(test, &mm),
   482						       "post-mm check failed\n");
   483			}
   484	
   485			if (err || timeout)
   486				break;
   487	
   488			cond_resched();
   489		}
   490	
   491		kfree(order);
   492		drm_buddy_fini(&mm);
   493	}
   494	

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




[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