From: SF Markus Elfring <elfring@users.sourceforge.net>
To: netdev@vger.kernel.org, Cong Wang <xiyou.wangcong@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Pirko <jiri@resnulli.us>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/2] net/sched/cls_tcindex: Improve a size determination in two functions
Date: Wed, 8 Nov 2017 21:38:18 +0100 [thread overview]
Message-ID: <a039fc85-62a0-1da9-dc32-fe2294bf8991@users.sourceforge.net> (raw)
In-Reply-To: <7192a5ea-b712-6bec-5d9d-01906218d404@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Nov 2017 21:17:26 +0100
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sched/cls_tcindex.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 24f05bc09084..0f1909c6545d 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -130,7 +130,7 @@ static int tcindex_init(struct tcf_proto *tp)
struct tcindex_data *p;
pr_debug("tcindex_init(tp %p)\n", tp);
- p = kzalloc(sizeof(struct tcindex_data), GFP_KERNEL);
+ p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -413,10 +413,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
} else {
struct tcindex_filter __rcu **hash;
- hash = kcalloc(cp->hash,
- sizeof(struct tcindex_filter *),
- GFP_KERNEL);
-
+ hash = kcalloc(cp->hash, sizeof(*hash), GFP_KERNEL);
if (!hash)
goto errout_alloc;
--
2.15.0
prev parent reply other threads:[~2017-11-08 20:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 20:34 [PATCH 0/2] net/sched/cls_tcindex: Fine-tuning for two function implementations SF Markus Elfring
2017-11-08 20:36 ` [PATCH 1/2] net/sched/cls_tcindex: Use common error handling code in tcindex_set_parms() SF Markus Elfring
2017-11-08 20:38 ` SF Markus Elfring [this message]
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=a039fc85-62a0-1da9-dc32-fe2294bf8991@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/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).