[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c5a1a54-abed-9fd7-cce1-dc9f7c06ef24@intel.com>
Date: Fri, 10 Feb 2023 11:33:47 -0800
From: Jacob Keller <jacob.e.keller@...el.com>
To: Jiri Pirko <jiri@...nulli.us>, <netdev@...r.kernel.org>
CC: <davem@...emloft.net>, <kuba@...nel.org>, <pabeni@...hat.com>,
<edumazet@...gle.com>, <tariqt@...dia.com>, <saeedm@...dia.com>,
<gal@...dia.com>, <kim.phillips@....com>, <moshe@...dia.com>,
<simon.horman@...igine.com>, <idosch@...dia.com>
Subject: Re: [patch net-next v2 1/7] devlink: don't use strcpy() to copy param
value
On 2/10/2023 2:01 AM, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@...dia.com>
>
> No need to treat string params any different comparing to other types.
> Rely on the struct assign to copy the whole struct, including the
> string.
I suspect the strcpy came from thinking about it as if it stored a
pointer to the string and not as an array struct member.
Makes sense.
Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>
>
> Signed-off-by: Jiri Pirko <jiri@...dia.com>
> Reviewed-by: Simon Horman <simon.horman@...igine.com>
> Acked-by: Jakub Kicinski <kuba@...nel.org>
> ---
> net/devlink/leftover.c | 15 +++------------
> 1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
> index f05ab093d231..f2f6a2f42864 100644
> --- a/net/devlink/leftover.c
> +++ b/net/devlink/leftover.c
> @@ -4388,10 +4388,7 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
> return -EOPNOTSUPP;
>
> if (cmode == DEVLINK_PARAM_CMODE_DRIVERINIT) {
> - if (param->type == DEVLINK_PARAM_TYPE_STRING)
> - strcpy(param_item->driverinit_value.vstr, value.vstr);
> - else
> - param_item->driverinit_value = value;
> + param_item->driverinit_value = value;
> param_item->driverinit_value_valid = true;
> } else {
> if (!param->set)
> @@ -9656,10 +9653,7 @@ int devl_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
> DEVLINK_PARAM_CMODE_DRIVERINIT)))
> return -EOPNOTSUPP;
>
> - if (param_item->param->type == DEVLINK_PARAM_TYPE_STRING)
> - strcpy(init_val->vstr, param_item->driverinit_value.vstr);
> - else
> - *init_val = param_item->driverinit_value;
> + *init_val = param_item->driverinit_value;
>
> return 0;
> }
> @@ -9690,10 +9684,7 @@ void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
> DEVLINK_PARAM_CMODE_DRIVERINIT)))
> return;
>
> - if (param_item->param->type == DEVLINK_PARAM_TYPE_STRING)
> - strcpy(param_item->driverinit_value.vstr, init_val.vstr);
> - else
> - param_item->driverinit_value = init_val;
> + param_item->driverinit_value = init_val;
> param_item->driverinit_value_valid = true;
>
> devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
Powered by blists - more mailing lists