[openeuler:OLK-6.6 3542/3542] lib/test_hexdump.c:116:3: warning: 'strncpy' output truncated copying between 0 and 32 bytes from a string of length 32
tree: https://gitee.com/openeuler/kernel.git OLK-6.6 head: 81b22958142c03b02c766c79cd1554ebfa142be4 commit: f04c0f3eb9b49427c273cd3e4d5a2ff895855b4b [3542/3542] make OPTIMIZE_INLINING config editable config: arm64-randconfig-004-20251215 (https://download.01.org/0day-ci/archive/20251215/202512151641.xBwOsIKs-lkp@i...) compiler: aarch64-linux-gcc (GCC) 9.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151641.xBwOsIKs-lkp@i...) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202512151641.xBwOsIKs-lkp@intel.com/ All warnings (new ones prefixed by >>): lib/test_hexdump.c: In function 'test_hexdump_prepare_test.isra.0':
lib/test_hexdump.c:116:3: warning: 'strncpy' output truncated copying between 0 and 32 bytes from a string of length 32 [-Wstringop-truncation] 116 | strncpy(p, data_a, l); | ^~~~~~~~~~~~~~~~~~~~~
vim +/strncpy +116 lib/test_hexdump.c 7aaf4c3e1235cc lib/test_hexdump.c Andy Shevchenko 2016-01-20 66 87977ca6bcd051 lib/test_hexdump.c Andy Shevchenko 2016-01-20 67 static void __init test_hexdump_prepare_test(size_t len, int rowsize, 87977ca6bcd051 lib/test_hexdump.c Andy Shevchenko 2016-01-20 68 int groupsize, char *test, 87977ca6bcd051 lib/test_hexdump.c Andy Shevchenko 2016-01-20 69 size_t testlen, bool ascii) 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 70 { 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 71 char *p; 17974c054db303 lib/test-hexdump.c Linus Torvalds 2015-04-19 72 const char * const *result; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 73 size_t l = len; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 74 int gs = groupsize, rs = rowsize; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 75 unsigned int i; de9df3993cfffd lib/test_hexdump.c Christophe Leroy 2018-08-21 76 const bool is_be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN); 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 77 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 78 if (rs != 16 && rs != 32) 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 79 rs = 16; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 80 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 81 if (l > rs) 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 82 l = rs; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 83 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 84 if (!is_power_of_2(gs) || gs > 8 || (len % gs != 0)) 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 85 gs = 1; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 86 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 87 if (gs == 8) de9df3993cfffd lib/test_hexdump.c Christophe Leroy 2018-08-21 88 result = is_be ? test_data_8_be : test_data_8_le; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 89 else if (gs == 4) de9df3993cfffd lib/test_hexdump.c Christophe Leroy 2018-08-21 90 result = is_be ? test_data_4_be : test_data_4_le; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 91 else if (gs == 2) de9df3993cfffd lib/test_hexdump.c Christophe Leroy 2018-08-21 92 result = is_be ? test_data_2_be : test_data_2_le; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 93 else de9df3993cfffd lib/test_hexdump.c Christophe Leroy 2018-08-21 94 result = test_data_1; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 95 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 96 /* hex dump */ 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 97 p = test; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 98 for (i = 0; i < l / gs; i++) { 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 99 const char *q = *result++; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 100 size_t amount = strlen(q); 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 101 b1286ed7158e9b lib/test_hexdump.c Linus Torvalds 2018-11-30 102 memcpy(p, q, amount); 3db4a987180acf lib/test_hexdump.c Andy Shevchenko 2016-01-20 103 p += amount; 3db4a987180acf lib/test_hexdump.c Andy Shevchenko 2016-01-20 104 3db4a987180acf lib/test_hexdump.c Andy Shevchenko 2016-01-20 105 *p++ = ' '; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 106 } 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 107 if (i) 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 108 p--; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 109 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 110 /* ASCII part */ 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 111 if (ascii) { 3db4a987180acf lib/test_hexdump.c Andy Shevchenko 2016-01-20 112 do { 3db4a987180acf lib/test_hexdump.c Andy Shevchenko 2016-01-20 113 *p++ = ' '; 3db4a987180acf lib/test_hexdump.c Andy Shevchenko 2016-01-20 114 } while (p < test + rs * 2 + rs / gs + 1); 3db4a987180acf lib/test_hexdump.c Andy Shevchenko 2016-01-20 115 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 @116 strncpy(p, data_a, l); 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 117 p += l; 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 118 } 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 119 64d1d77a44697a lib/test-hexdump.c Andy Shevchenko 2015-02-12 120 *p = '\0'; 87977ca6bcd051 lib/test_hexdump.c Andy Shevchenko 2016-01-20 121 } 87977ca6bcd051 lib/test_hexdump.c Andy Shevchenko 2016-01-20 122 :::::: The code at line 116 was first introduced by commit :::::: 64d1d77a44697af8e314939ecef30642c68309cb hexdump: introduce test suite :::::: TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com> :::::: CC: Linus Torvalds <torvalds@linux-foundation.org> -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
participants (1)
-
kernel test robot