[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5688a15f-48d1-4560-9358-ec83fb623205@huawei.com>
Date: Thu, 24 Oct 2024 12:02:45 +0800
From: Jijie Shao <shaojijie@...wei.com>
To: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <andrew+netdev@...n.ch>, <horms@...nel.org>
CC: <shaojijie@...wei.com>, <shenjian15@...wei.com>,
<wangpeiyang1@...wei.com>, <liuyonglong@...wei.com>, <chenhao418@...wei.com>,
<sudongming1@...wei.com>, <xujunsheng@...wei.com>, <shiyongbang@...wei.com>,
<libaihan@...wei.com>, <jonathan.cameron@...wei.com>,
<shameerali.kolothum.thodi@...wei.com>, <salil.mehta@...wei.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next 4/7] net: hibmcge: Add register dump supported in
this module
on 2024/10/23 21:42, Jijie Shao wrote:
>
> +#define HBG_REG_NAEM_MAX_LEN 24
> +#define HBG_REG_TYPE_MAX_LEN 8
......
> +
> +struct hbg_reg_offset_name_map {
> + u32 reg_offset;
> + char name[HBG_REG_NAEM_MAX_LEN];
> +};
> +
> +struct hbg_reg_type_info {
> + char name[HBG_REG_TYPE_MAX_LEN];
> + u32 offset_base;
> + const struct hbg_reg_offset_name_map *reg_maps;
> + u32 reg_num;
> +};
> +
> +struct hbg_reg_info {
> + char name[HBG_REG_NAEM_MAX_LEN + HBG_REG_TYPE_MAX_LEN];
> + u32 offset;
> + u32 val;
......
> +
> +static u32 hbg_get_reg_info(struct hbg_priv *priv,
> + const struct hbg_reg_type_info *type_info,
> + const struct hbg_reg_offset_name_map *reg_map,
> + struct hbg_reg_info *info)
> +{
> + info->val = hbg_reg_read(priv, reg_map->reg_offset);
> + info->offset = reg_map->reg_offset - type_info->offset_base;
> + snprintf(info->name, sizeof(info->name),
> + "[%s] %s", type_info->name, reg_map->name);
> +
In addition, there are compilation warning here:
../drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c: In function ‘hbg_ethtool_get_regs’:
../drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c:322:20: warning: ‘%s’ directive output may be truncated writing up to 127 bytes into a region of size 31 [-Wformat-truncation=]
322 | "[%s] %s", type_info->name, reg_map->name);
| ^~
In function ‘hbg_get_reg_info’,
inlined from ‘hbg_ethtool_get_regs’ at ../drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c:338:14:
../drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c:321:9: note: ‘snprintf’ output between 4 and 154 bytes into a destination of size 32
321 | snprintf(info->name, sizeof(info->name),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322 | "[%s] %s", type_info->name, reg_map->name);
But in fact, sizeof(info->name) is (24+8), type_info->name length is 8, and reg_map->name length is 24.
I understand that it should be fine to use here.
Thanks,
Jijie Shao
Powered by blists - more mailing lists