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

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