Message ID | 20230210100131.3088240-2-jiri@resnulli.us (mailing list archive) |
---|---|
State | Accepted |
Commit | fa2f921f3bf1ed98956ad341b920a55aab69bc35 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | devlink: params cleanups and devl_param_driverinit_value_get() fix | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/cc_maintainers | success | CCed 6 of 6 maintainers |
netdev/build_clang | success | Errors and warnings before: 1 this patch: 1 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 33 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On 2/10/2023 2:01 AM, Jiri Pirko wrote: > From: Jiri Pirko <jiri@nvidia.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@intel.com> > > Signed-off-by: Jiri Pirko <jiri@nvidia.com> > Reviewed-by: Simon Horman <simon.horman@corigine.com> > Acked-by: Jakub Kicinski <kuba@kernel.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);
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);