drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:90:25: warning: 'strncpy' specified bound depends on the length of the source argument
From: kernel test robot
Date: Sun Nov 07 2021 - 23:19:15 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 6b75d88fa81b122cce37ebf17428a849ccd3d0f1
commit: 1556ea9120ffcf4faf7ac6b62a6e28216f260a23 net: hns3: refactor dump mac list of debugfs
date: 6 months ago
config: ia64-randconfig-r026-20211102 (attached as .config)
compiler: ia64-linux-gcc (GCC) 11.2.0
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/torvalds/linux.git/commit/?id=1556ea9120ffcf4faf7ac6b62a6e28216f260a23
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 1556ea9120ffcf4faf7ac6b62a6e28216f260a23
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All warnings (new ones prefixed by >>):
In file included from arch/ia64/include/asm/pgtable.h:154,
from include/linux/pgtable.h:6,
from include/linux/mm.h:33,
from include/linux/bvec.h:14,
from include/linux/skbuff.h:17,
from include/linux/if_ether.h:19,
from include/linux/etherdevice.h:20,
from drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h:7,
from drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:6:
arch/ia64/include/asm/mmu_context.h: In function 'reload_context':
arch/ia64/include/asm/mmu_context.h:127:48: warning: variable 'old_rr4' set but not used [-Wunused-but-set-variable]
127 | unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
| ^~~~~~~
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c: In function 'hclge_dbg_fill_content.constprop':
>> drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:90:25: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
90 | strncpy(pos, items[i].name, strlen(items[i].name));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:88:25: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
88 | strncpy(pos, result[i], strlen(result[i]));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/strncpy +90 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
5
> 6 #include "hclge_debugfs.h"
7 #include "hclge_main.h"
8 #include "hclge_tm.h"
9 #include "hnae3.h"
10
11 static const char * const hclge_mac_state_str[] = {
12 "TO_ADD", "TO_DEL", "ACTIVE"
13 };
14
15 static const struct hclge_dbg_reg_type_info hclge_dbg_reg_info[] = {
16 { .reg_type = "bios common",
17 .dfx_msg = &hclge_dbg_bios_common_reg[0],
18 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_bios_common_reg),
19 .offset = HCLGE_DBG_DFX_BIOS_OFFSET,
20 .cmd = HCLGE_OPC_DFX_BIOS_COMMON_REG } },
21 { .reg_type = "ssu",
22 .dfx_msg = &hclge_dbg_ssu_reg_0[0],
23 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_ssu_reg_0),
24 .offset = HCLGE_DBG_DFX_SSU_0_OFFSET,
25 .cmd = HCLGE_OPC_DFX_SSU_REG_0 } },
26 { .reg_type = "ssu",
27 .dfx_msg = &hclge_dbg_ssu_reg_1[0],
28 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_ssu_reg_1),
29 .offset = HCLGE_DBG_DFX_SSU_1_OFFSET,
30 .cmd = HCLGE_OPC_DFX_SSU_REG_1 } },
31 { .reg_type = "ssu",
32 .dfx_msg = &hclge_dbg_ssu_reg_2[0],
33 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_ssu_reg_2),
34 .offset = HCLGE_DBG_DFX_SSU_2_OFFSET,
35 .cmd = HCLGE_OPC_DFX_SSU_REG_2 } },
36 { .reg_type = "igu egu",
37 .dfx_msg = &hclge_dbg_igu_egu_reg[0],
38 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_igu_egu_reg),
39 .offset = HCLGE_DBG_DFX_IGU_OFFSET,
40 .cmd = HCLGE_OPC_DFX_IGU_EGU_REG } },
41 { .reg_type = "rpu",
42 .dfx_msg = &hclge_dbg_rpu_reg_0[0],
43 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_rpu_reg_0),
44 .offset = HCLGE_DBG_DFX_RPU_0_OFFSET,
45 .cmd = HCLGE_OPC_DFX_RPU_REG_0 } },
46 { .reg_type = "rpu",
47 .dfx_msg = &hclge_dbg_rpu_reg_1[0],
48 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_rpu_reg_1),
49 .offset = HCLGE_DBG_DFX_RPU_1_OFFSET,
50 .cmd = HCLGE_OPC_DFX_RPU_REG_1 } },
51 { .reg_type = "ncsi",
52 .dfx_msg = &hclge_dbg_ncsi_reg[0],
53 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_ncsi_reg),
54 .offset = HCLGE_DBG_DFX_NCSI_OFFSET,
55 .cmd = HCLGE_OPC_DFX_NCSI_REG } },
56 { .reg_type = "rtc",
57 .dfx_msg = &hclge_dbg_rtc_reg[0],
58 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_rtc_reg),
59 .offset = HCLGE_DBG_DFX_RTC_OFFSET,
60 .cmd = HCLGE_OPC_DFX_RTC_REG } },
61 { .reg_type = "ppp",
62 .dfx_msg = &hclge_dbg_ppp_reg[0],
63 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_ppp_reg),
64 .offset = HCLGE_DBG_DFX_PPP_OFFSET,
65 .cmd = HCLGE_OPC_DFX_PPP_REG } },
66 { .reg_type = "rcb",
67 .dfx_msg = &hclge_dbg_rcb_reg[0],
68 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_rcb_reg),
69 .offset = HCLGE_DBG_DFX_RCB_OFFSET,
70 .cmd = HCLGE_OPC_DFX_RCB_REG } },
71 { .reg_type = "tqp",
72 .dfx_msg = &hclge_dbg_tqp_reg[0],
73 .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_tqp_reg),
74 .offset = HCLGE_DBG_DFX_TQP_OFFSET,
75 .cmd = HCLGE_OPC_DFX_TQP_REG } },
76 };
77
78 static void hclge_dbg_fill_content(char *content, u16 len,
79 const struct hclge_dbg_item *items,
80 const char **result, u16 size)
81 {
82 char *pos = content;
83 u16 i;
84
85 memset(content, ' ', len);
86 for (i = 0; i < size; i++) {
87 if (result)
88 strncpy(pos, result[i], strlen(result[i]));
89 else
> 90 strncpy(pos, items[i].name, strlen(items[i].name));
91 pos += strlen(items[i].name) + items[i].interval;
92 }
93 *pos++ = '\n';
94 *pos++ = '\0';
95 }
96
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip