genetlink: remove superfluous assignment
Subsystems (2)
PATCH 1/1 genetlink: remove superfluous assignment
the local variable ops and n_ops were just read out from family, and not changed, why need to assign back?
Validation functions should operate on const parameters and not change anything.
--- net/netlink/genetlink.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/netlink/genetlink.c +1 -5
@@ -307,39 +307,35 @@genl_ctrl_event (CTRL_CMD_DELMCAST_GRP , family, &family->mcgrps[i], grp_id); } } -static int genl_validate_ops (struct genl_family *family) +static int genl_validate_ops (const struct genl_family *family) {const struct genl_ops *ops = family->ops;unsigned int n_ops = family->n_ops;int i, j;if (WARN_ON (n_ops && !ops))return -EINVAL ;if (!n_ops)return 0 ;for (i =0 ; i < n_ops; i++) {if (ops[i].dumpit ==NULL && ops[i].doit ==NULL )return -EINVAL ;for (j = i +1 ; j < n_ops; j++)if (ops[i].cmd == ops[j].cmd)return -EINVAL ; } -/* family is not registered yet, so no locking needed */ - family->ops = ops; - family->n_ops = n_ops; -return 0 ; }
David Miller
maintainerFrom: Cheng Renquan <[email protected]>
Date: Wed, 28 May 2014 23:54:08 -0700
Quoted 7 lines
the local variable ops and
n_opswere just read out from family, and not changed, why need to assign back?Validation functions should operate on const parameters and not change anything.
Signed-off-by Cheng Renquan <[email protected]>
This patch was corrupted by your email client, please fix this up and resubmit.
PATCH 1/1 genetlink: remove superfluous assignment
In reply to Cheng Renquanthe local variable ops and n_ops were just read out from family, and not changed, hence no need to assign back.
Validation functions should operate on const parameters and not change anything.
--- net/netlink/genetlink.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/netlink/genetlink.c +1 -5
@@ -309,46 +309,42 @@ static void genl_unregister_mc_groups(struct genl_family *family)for (i =0 ; i < family->n_mcgrps; i++) {int grp_id = family->mcgrp_offset + i;if (grp_id !=1 )clear_bit (grp_id, mc_groups);genl_ctrl_event (CTRL_CMD_DELMCAST_GRP , family, &family->mcgrps[i], grp_id); } } -static int genl_validate_ops (struct genl_family *family) +static int genl_validate_ops (const struct genl_family *family) {const struct genl_ops *ops = family->ops;unsigned int n_ops = family->n_ops;int i, j;if (WARN_ON (n_ops && !ops))return -EINVAL ;if (!n_ops)return 0 ;for (i =0 ; i < n_ops; i++) {if (ops[i].dumpit ==NULL && ops[i].doit ==NULL )return -EINVAL ;for (j = i +1 ; j < n_ops; j++)if (ops[i].cmd == ops[j].cmd)return -EINVAL ; } -/* family is not registered yet, so no locking needed */ - family->ops = ops; - family->n_ops = n_ops; -return 0 ; }/** * __genl_register_family - register a generic netlink family * @family: generic netlink family * * Registers the specified family after validating it first. Only one * family may be registered with the same family name or identifier. * The family id may equal GENL_ID_GENERATE causing an unique id to * be automatically generated and assigned.
From: [email protected]
Date: Mon, 2 Jun 2014 01:18:01 -0700
Quoted 7 lines
the local variable ops and
n_opswere just read out from family, and not changed, hence no need to assign back.Validation functions should operate on const parameters and not change anything.
Signed-off-by Cheng Renquan <[email protected]>
Applied, thanks Cheng.