netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: crquan@gmail.com
To: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH] genetlink: remove superfluous assignment
Date: Mon,  2 Jun 2014 01:18:01 -0700	[thread overview]
Message-ID: <1401697081-17093-1-git-send-email-crquan@gmail.com> (raw)
In-Reply-To: <1401346448-17105-1-git-send-email-crquan@gmail.com>

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.

  parent reply	other threads:[~2014-06-02  8:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2014-06-02 17:36   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401697081-17093-1-git-send-email-crquan@gmail.com \
    --to=crquan@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).