netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] genetlink: remove superfluous assignment
@ 2014-05-29  6:54 Cheng Renquan
  2014-06-02  5:11 ` David Miller
  2014-06-02  8:18 ` crquan
  0 siblings, 2 replies; 4+ messages in thread
From: Cheng Renquan @ 2014-05-29  6:54 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: Johannes Berg

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.

Signed-off-by: Cheng Renquan <crquan@gmail.com>

---
 net/netlink/genetlink.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Index: linux-3.14.3/net/netlink/genetlink.c
===================================================================
--- linux-3.14.3.orig/net/netlink/genetlink.c	2014-05-06 07:59:58.000000000 -0700
+++ linux-3.14.3/net/netlink/genetlink.c	2014-05-28 23:42:46.325410152 -0700
@@ -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;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] genetlink: remove superfluous assignment
  2014-05-29  6:54 [PATCH] genetlink: remove superfluous assignment Cheng Renquan
@ 2014-06-02  5:11 ` David Miller
  2014-06-02  8:18 ` crquan
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-06-02  5:11 UTC (permalink / raw)
  To: crquan; +Cc: netdev, johannes.berg

From: Cheng Renquan <crquan@gmail.com>
Date: Wed, 28 May 2014 23:54:08 -0700

> 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.
> 
> Signed-off-by: Cheng Renquan <crquan@gmail.com>

This patch was corrupted by your email client, please fix this up
and resubmit.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] genetlink: remove superfluous assignment
  2014-05-29  6:54 [PATCH] genetlink: remove superfluous assignment Cheng Renquan
  2014-06-02  5:11 ` David Miller
@ 2014-06-02  8:18 ` crquan
  2014-06-02 17:36   ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: crquan @ 2014-06-02  8:18 UTC (permalink / raw)
  To: David S. Miller, netdev

the 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.

Signed-off-by: Cheng Renquan <crquan@gmail.com>
---
 net/netlink/genetlink.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index a3ba3ca..76393f2 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -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.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] genetlink: remove superfluous assignment
  2014-06-02  8:18 ` crquan
@ 2014-06-02 17:36   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-06-02 17:36 UTC (permalink / raw)
  To: crquan; +Cc: netdev

From: crquan@gmail.com
Date: Mon,  2 Jun 2014 01:18:01 -0700

> the 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.
> 
> Signed-off-by: Cheng Renquan <crquan@gmail.com>

Applied, thanks Cheng.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-02 17:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-29  6:54 [PATCH] genetlink: remove superfluous assignment Cheng Renquan
2014-06-02  5:11 ` David Miller
2014-06-02  8:18 ` crquan
2014-06-02 17:36   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).