[linux-next:master 1399/5845] kernel/module/main.c:1477:26: warning: Redundant assignment of 'mod->data_layout.size' to itself. [selfAssignment]

[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:   e7d6987e09a328d4a949701db40ef63fbb970670
commit: 01dc0386efb769056257410ba5754558384006a7 [1399/5845] module: Add CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC
compiler: powerpc64-linux-gcc (GCC) 11.2.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 01dc0386efb769056257410ba5754558384006a7
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

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


cppcheck warnings: (new ones prefixed by >>)
   kernel/module/main.c:1473:26: warning: Redundant assignment of 'mod->core_layout.size' to itself. [selfAssignment]
      mod->core_layout.size = strict_align(mod->core_layout.size);
                            ^
   kernel/module/main.c:1507:26: warning: Redundant assignment of 'mod->init_layout.size' to itself. [selfAssignment]
      mod->init_layout.size = strict_align(mod->init_layout.size);
                            ^
   kernel/module/main.c:1511:26: warning: Redundant assignment of 'mod->init_layout.size' to itself. [selfAssignment]
      mod->init_layout.size = strict_align(mod->init_layout.size);
                            ^
   kernel/module/main.c:1522:26: warning: Redundant assignment of 'mod->init_layout.size' to itself. [selfAssignment]
      mod->init_layout.size = strict_align(mod->init_layout.size);
                            ^
   kernel/module/main.c:338:20: warning: Local variable 'arr' shadows outer variable [shadowVariable]
     struct symsearch arr[] = {
                      ^
   kernel/module/main.c:320:32: note: Shadowed declaration
    static const struct symsearch arr[] = {
                                  ^
   kernel/module/main.c:338:20: note: Shadow variable
     struct symsearch arr[] = {
                      ^
>> kernel/module/main.c:1477:26: warning: Redundant assignment of 'mod->data_layout.size' to itself. [selfAssignment]
      mod->data_layout.size = strict_align(mod->data_layout.size);
                            ^
   kernel/module/main.c:1481:26: warning: Redundant assignment of 'mod->data_layout.size' to itself. [selfAssignment]
      mod->data_layout.size = strict_align(mod->data_layout.size);
                            ^
   kernel/module/main.c:1485:26: warning: Redundant assignment of 'mod->data_layout.size' to itself. [selfAssignment]
      mod->data_layout.size = strict_align(mod->data_layout.size);
                            ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

   kernel/module/main.c:1621:70: warning: Parameter 'debug' can be declared with const [constParameter]
   static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug)
                                                                        ^

vim +1477 kernel/module/main.c

055f23b74b20f2 kernel/module.c      Jessica Yu       2021-05-12  1429  
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1430  /*
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1431   * Lay out the SHF_ALLOC sections in a way not dissimilar to how ld
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1432   * might -- code, read-only data, read-write data, small data.  Tally
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1433   * sizes, and place the offsets into sh_entsize fields: high bit means it
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1434   * belongs in init.
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1435   */
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1436  static void layout_sections(struct module *mod, struct load_info *info)
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1437  {
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1438  	static unsigned long const masks[][2] = {
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1439  		/*
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1440  		 * NOTE: all executable code must be the first section
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1441  		 * in this array; otherwise modify the text_size
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1442  		 * finder in the two loops below
24b9f0d2208145 kernel/module.c      Sergey Shtylyov  2020-11-07  1443  		 */
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1444  		{ SHF_EXECINSTR | SHF_ALLOC, ARCH_SHF_SMALL },
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1445  		{ SHF_ALLOC, SHF_WRITE | ARCH_SHF_SMALL },
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1446  		{ SHF_RO_AFTER_INIT | SHF_ALLOC, ARCH_SHF_SMALL },
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1447  		{ SHF_WRITE | SHF_ALLOC, ARCH_SHF_SMALL },
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1448  		{ ARCH_SHF_SMALL | SHF_ALLOC, 0 }
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1449  	};
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1450  	unsigned int m, i;
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1451  
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1452  	for (i = 0; i < info->hdr->e_shnum; i++)
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1453  		info->sechdrs[i].sh_entsize = ~0UL;
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1454  
5e12416927975a kernel/module.c      Jim Cromie       2011-12-06  1455  	pr_debug("Core section allocation order:\n");
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1456  	for (m = 0; m < ARRAY_SIZE(masks); ++m) {
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1457  		for (i = 0; i < info->hdr->e_shnum; ++i) {
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1458  			Elf_Shdr *s = &info->sechdrs[i];
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1459  			const char *sname = info->secstrings + s->sh_name;
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23  1460  			unsigned int *sizep;
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1461  
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1462  			if ((s->sh_flags & masks[m][0]) != masks[m][0]
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1463  			    || (s->sh_flags & masks[m][1])
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1464  			    || s->sh_entsize != ~0UL
055f23b74b20f2 kernel/module.c      Jessica Yu       2021-05-12  1465  			    || module_init_layout_section(sname))
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1466  				continue;
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23  1467  			sizep = m ? &mod->data_layout.size : &mod->core_layout.size;
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23  1468  			s->sh_entsize = module_get_offset(mod, sizep, s, i);
5e12416927975a kernel/module.c      Jim Cromie       2011-12-06  1469  			pr_debug("\t%s\n", sname);
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1470  		}
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1471  		switch (m) {
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1472  		case 0: /* executable */
7337f929d5672e kernel/module/main.c Christophe Leroy 2022-02-23  1473  			mod->core_layout.size = strict_align(mod->core_layout.size);
7523e4dc5057e1 kernel/module.c      Rusty Russell    2015-11-26  1474  			mod->core_layout.text_size = mod->core_layout.size;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1475  			break;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1476  		case 1: /* RO: text and ro-data */
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23 @1477  			mod->data_layout.size = strict_align(mod->data_layout.size);
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23  1478  			mod->data_layout.ro_size = mod->data_layout.size;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1479  			break;
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1480  		case 2: /* RO after init */
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23  1481  			mod->data_layout.size = strict_align(mod->data_layout.size);
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23  1482  			mod->data_layout.ro_after_init_size = mod->data_layout.size;
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1483  			break;
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1484  		case 4: /* whole core */
6ab9942c44b2d2 kernel/module/main.c Christophe Leroy 2022-02-23  1485  			mod->data_layout.size = strict_align(mod->data_layout.size);
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1486  			break;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1487  		}
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1488  	}
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1489  
5e12416927975a kernel/module.c      Jim Cromie       2011-12-06  1490  	pr_debug("Init section allocation order:\n");
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1491  	for (m = 0; m < ARRAY_SIZE(masks); ++m) {
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1492  		for (i = 0; i < info->hdr->e_shnum; ++i) {
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1493  			Elf_Shdr *s = &info->sechdrs[i];
49668688dd5a5f kernel/module.c      Rusty Russell    2010-08-05  1494  			const char *sname = info->secstrings + s->sh_name;
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1495  
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1496  			if ((s->sh_flags & masks[m][0]) != masks[m][0]
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1497  			    || (s->sh_flags & masks[m][1])
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1498  			    || s->sh_entsize != ~0UL
055f23b74b20f2 kernel/module.c      Jessica Yu       2021-05-12  1499  			    || !module_init_layout_section(sname))
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1500  				continue;
91fb02f31505dc kernel/module/main.c Aaron Tomlin     2022-03-22  1501  			s->sh_entsize = (module_get_offset(mod, &mod->init_layout.size, s, i)
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1502  					 | INIT_OFFSET_MASK);
5e12416927975a kernel/module.c      Jim Cromie       2011-12-06  1503  			pr_debug("\t%s\n", sname);
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1504  		}
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1505  		switch (m) {
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1506  		case 0: /* executable */
7337f929d5672e kernel/module/main.c Christophe Leroy 2022-02-23  1507  			mod->init_layout.size = strict_align(mod->init_layout.size);
7523e4dc5057e1 kernel/module.c      Rusty Russell    2015-11-26  1508  			mod->init_layout.text_size = mod->init_layout.size;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1509  			break;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1510  		case 1: /* RO: text and ro-data */
7337f929d5672e kernel/module/main.c Christophe Leroy 2022-02-23  1511  			mod->init_layout.size = strict_align(mod->init_layout.size);
7523e4dc5057e1 kernel/module.c      Rusty Russell    2015-11-26  1512  			mod->init_layout.ro_size = mod->init_layout.size;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1513  			break;
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1514  		case 2:
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1515  			/*
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1516  			 * RO after init doesn't apply to init_layout (only
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1517  			 * core_layout), so it just takes the value of ro_size.
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1518  			 */
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1519  			mod->init_layout.ro_after_init_size = mod->init_layout.ro_size;
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1520  			break;
444d13ff10fb13 kernel/module.c      Jessica Yu       2016-07-27  1521  		case 4: /* whole init */
7337f929d5672e kernel/module/main.c Christophe Leroy 2022-02-23  1522  			mod->init_layout.size = strict_align(mod->init_layout.size);
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1523  			break;
84e1c6bb38eb31 kernel/module.c      Matthieu CASTET  2010-11-16  1524  		}
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1525  	}
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1526  }
^1da177e4c3f41 kernel/module.c      Linus Torvalds   2005-04-16  1527  

:::::: The code at line 1477 was first introduced by commit
:::::: 6ab9942c44b2d213a16b2620e4baf0223122222f module: Introduce data_layout

:::::: TO: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
:::::: CC: Luis Chamberlain <mcgrof@xxxxxxxxxx>

-- 
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