[PATCH v3 39/65] net/hns3: use kvargs numeric helpers
fengchengwen
fengchengwen at huawei.com
Sat Oct 10 04:36:29 CEST 2026
On 10/1/2026 6:40 AM, Stephen Hemminger wrote:
> hns3_parse_mbx_time_limit() checks neither errno nor the end pointer, so
> a malformed value such as "abc" is taken as zero and then silently
> ignored by the range test that follows.
>
> The range test is now part of the conversion, which keeps the existing
> behaviour of leaving the default in place when the value is out of
> range.
>
> The device capability mask parser is converted separately, later in this
> series, since it needs the hexadecimal handler rather than a decimal one.
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> drivers/net/hns3/hns3_common.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c
> index 29b51856d9..c21740ba5e 100644
> --- a/drivers/net/hns3/hns3_common.c
> +++ b/drivers/net/hns3/hns3_common.c
> @@ -231,14 +231,13 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args)
> if (value == NULL || extra_args == NULL)
> return 0;
>
> - val = strtoul(value, NULL, HNS3_CONVERT_TO_DECIMAL);
> -
> /*
> * 500ms is empirical value in process of mailbox communication. If
> * the delay value is set to one lower than the empirical value, mailbox
> * communication may fail.
> */
> - if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX)
> + if (rte_kvargs_to_uint(value, HNS3_MBX_DEF_TIME_LIMIT_MS + 1,
> + UINT16_MAX, &val) == 0)
It should be:
if (rte_kvargs_to_uint(value, HNS3_MBX_DEF_TIME_LIMIT_MS,
UINT16_MAX, &val) == 0)
Thanks
> *(uint16_t *)extra_args = val;
>
> return 0;
More information about the dev
mailing list