summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Pirko <jiri@nvidia.com>2023-02-10 11:01:25 +0100
committerDavid S. Miller <davem@davemloft.net>2023-02-13 09:49:14 +0000
commitfa2f921f3bf1ed98956ad341b920a55aab69bc35 (patch)
treecf9aafcbb3c177bd5a3d80452a02b30efc1a6972
parent170677fee45baa955b3f7c1f41e6031d1d1e2272 (diff)
devlink: don't use strcpy() to copy param value
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. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/devlink/leftover.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
index 61b51ed287b3..2f9e309727c7 100644
--- a/net/devlink/leftover.c
+++ b/net/devlink/leftover.c
@@ -4387,10 +4387,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)
@@ -9655,10 +9652,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;
}
@@ -9689,10 +9683,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);