Commit 501543b4 authored by Dan Carpenter's avatar Dan Carpenter Committed by Paolo Abeni

devlink: remove some unnecessary code

This code checks if (attrs[DEVLINK_ATTR_TRAP_POLICER_ID]) twice.  Once
at the start of the function and then a couple lines later.  Delete the
second check since that one must be true.

Because the second condition is always true, it means the:

	policer_item = group_item->policer_item;

assignment is immediately over-written.  Delete that as well.
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/Y8EJz8oxpMhfiPUb@kiliSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 0349b877
...@@ -8719,6 +8719,7 @@ static int devlink_trap_group_set(struct devlink *devlink, ...@@ -8719,6 +8719,7 @@ static int devlink_trap_group_set(struct devlink *devlink,
struct netlink_ext_ack *extack = info->extack; struct netlink_ext_ack *extack = info->extack;
const struct devlink_trap_policer *policer; const struct devlink_trap_policer *policer;
struct nlattr **attrs = info->attrs; struct nlattr **attrs = info->attrs;
u32 policer_id;
int err; int err;
if (!attrs[DEVLINK_ATTR_TRAP_POLICER_ID]) if (!attrs[DEVLINK_ATTR_TRAP_POLICER_ID])
...@@ -8727,17 +8728,11 @@ static int devlink_trap_group_set(struct devlink *devlink, ...@@ -8727,17 +8728,11 @@ static int devlink_trap_group_set(struct devlink *devlink,
if (!devlink->ops->trap_group_set) if (!devlink->ops->trap_group_set)
return -EOPNOTSUPP; return -EOPNOTSUPP;
policer_item = group_item->policer_item; policer_id = nla_get_u32(attrs[DEVLINK_ATTR_TRAP_POLICER_ID]);
if (attrs[DEVLINK_ATTR_TRAP_POLICER_ID]) { policer_item = devlink_trap_policer_item_lookup(devlink, policer_id);
u32 policer_id; if (policer_id && !policer_item) {
NL_SET_ERR_MSG_MOD(extack, "Device did not register this trap policer");
policer_id = nla_get_u32(attrs[DEVLINK_ATTR_TRAP_POLICER_ID]); return -ENOENT;
policer_item = devlink_trap_policer_item_lookup(devlink,
policer_id);
if (policer_id && !policer_item) {
NL_SET_ERR_MSG_MOD(extack, "Device did not register this trap policer");
return -ENOENT;
}
} }
policer = policer_item ? policer_item->policer : NULL; policer = policer_item ? policer_item->policer : NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment