All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Parkin <tparkin@katalix.com>
To: netdev@vger.kernel.org
Cc: jchapman@katalix.com, Tom Parkin <tparkin@katalix.com>
Subject: [PATCH 6/6] l2tp: cleanup kzalloc calls
Date: Thu, 23 Jul 2020 12:29:55 +0100	[thread overview]
Message-ID: <20200723112955.19808-7-tparkin@katalix.com> (raw)
In-Reply-To: <20200723112955.19808-1-tparkin@katalix.com>

Passing "sizeof(struct blah)" in kzalloc calls is less readable,
potentially prone to future bugs if the type of the pointer is changed,
and triggers checkpatch warnings.

Tweak the kzalloc calls in l2tp which use this form to avoid the
warning.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
---
 net/l2tp/l2tp_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index d1403f27135e..7e3523015d6f 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1410,7 +1410,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
 	if (cfg)
 		encap = cfg->encap;
 
-	tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL);
+	tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL);
 	if (!tunnel) {
 		err = -ENOMEM;
 		goto err;
@@ -1647,7 +1647,7 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
 {
 	struct l2tp_session *session;
 
-	session = kzalloc(sizeof(struct l2tp_session) + priv_size, GFP_KERNEL);
+	session = kzalloc(sizeof(*session) + priv_size, GFP_KERNEL);
 	if (session) {
 		session->magic = L2TP_SESSION_MAGIC;
 		session->tunnel = tunnel;
-- 
2.17.1


  parent reply	other threads:[~2020-07-23 11:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 11:29 [PATCH net-next 0/6] l2tp: further checkpatch.pl cleanups Tom Parkin
2020-07-23 11:29 ` [PATCH 1/6] l2tp: cleanup comparisons to NULL Tom Parkin
2020-07-23 11:29 ` [PATCH 2/6] l2tp: cleanup unnecessary braces in if statements Tom Parkin
2020-07-23 11:29 ` [PATCH 3/6] l2tp: check socket address type in l2tp_dfs_seq_tunnel_show Tom Parkin
2020-07-23 11:29 ` [PATCH 4/6] l2tp: cleanup netlink send of tunnel address information Tom Parkin
2020-07-23 11:29 ` [PATCH 5/6] l2tp: cleanup netlink tunnel create address handling Tom Parkin
2020-07-23 11:29 ` Tom Parkin [this message]
2020-07-23 18:00 ` [PATCH net-next 0/6] l2tp: further checkpatch.pl cleanups James Chapman
2020-07-23 18:54   ` 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=20200723112955.19808-7-tparkin@katalix.com \
    --to=tparkin@katalix.com \
    --cc=jchapman@katalix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.