Skip to content

Commit

Permalink
devlink: remove some unnecessary code
Browse files Browse the repository at this point in the history
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: Dan Carpenter <error27@gmail.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/Y8EJz8oxpMhfiPUb@kili
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Dan Carpenter authored and Paolo Abeni committed Jan 17, 2023
1 parent 0349b87 commit 501543b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions net/devlink/leftover.c
Original file line number Diff line number Diff line change
Expand Up @@ -8719,6 +8719,7 @@ static int devlink_trap_group_set(struct devlink *devlink,
struct netlink_ext_ack *extack = info->extack;
const struct devlink_trap_policer *policer;
struct nlattr **attrs = info->attrs;
u32 policer_id;
int err;

if (!attrs[DEVLINK_ATTR_TRAP_POLICER_ID])
Expand All @@ -8727,17 +8728,11 @@ static int devlink_trap_group_set(struct devlink *devlink,
if (!devlink->ops->trap_group_set)
return -EOPNOTSUPP;

policer_item = group_item->policer_item;
if (attrs[DEVLINK_ATTR_TRAP_POLICER_ID]) {
u32 policer_id;

policer_id = nla_get_u32(attrs[DEVLINK_ATTR_TRAP_POLICER_ID]);
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_id = nla_get_u32(attrs[DEVLINK_ATTR_TRAP_POLICER_ID]);
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;

Expand Down

0 comments on commit 501543b

Please sign in to comment.