From: Cheng Renquan <crquan@gmail.com>
To: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH] genetlink: remove superfluous assignment
Date: Wed, 28 May 2014 23:54:08 -0700 [thread overview]
Message-ID: <1401346448-17105-1-git-send-email-crquan@gmail.com> (raw)
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;
}
next reply other threads:[~2014-05-29 6:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 6:54 Cheng Renquan [this message]
2014-06-02 5:11 ` [PATCH] genetlink: remove superfluous assignment David Miller
2014-06-02 8:18 ` crquan
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=1401346448-17105-1-git-send-email-crquan@gmail.com \
--to=crquan@gmail.com \
--cc=davem@davemloft.net \
--cc=johannes.berg@intel.com \
--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).