mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steffen Vogel <post@steffenvogel.de>
To: linux-kernel@vger.kernel.org
Cc: Evgeniy Polyakov <zbr@ioremap.net>, Joe Perches <joe@perches.com>,
	Steffen Vogel <post@steffenvogel.de>
Subject: [PATCH v2 10/12] w1: use pointers instead of types to determine size of allocs
Date: Mon, 29 Oct 2018 04:03:40 +0100	[thread overview]
Message-ID: <8d0079ed2b260a00bcaa906729325a4e8de66486.1540782140.git.post@steffenvogel.de> (raw)
In-Reply-To: <cover.1540782140.git.post@steffenvogel.de>

Get size of allocation based on pointer not type.

Signed-off-by: Steffen Vogel <post@steffenvogel.de>
---
 drivers/w1/w1.c     | 2 +-
 drivers/w1/w1_int.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 4cbe1849fbfc..87094d99ccbe 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -756,7 +756,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
 	int err;
 	struct w1_netlink_msg msg;
 
-	sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL);
+	sl = kzalloc(sizeof(*sl), GFP_KERNEL);
 	if (!sl)
 		return -ENOMEM;
 
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index a5230c0d49e3..2bf7631ac24f 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -31,7 +31,7 @@ static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
 	/*
 	 * We are in process context(kernel thread), so can sleep.
 	 */
-	dev = kzalloc(sizeof(struct w1_master) +
+	dev = kzalloc(sizeof(*dev) +
 		sizeof(struct w1_bus_master), GFP_KERNEL);
 	if (!dev)
 		return NULL;
-- 
2.11.0


  parent reply	other threads:[~2018-10-29  3:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29  3:03 [PATCH v2 00/11] w1: coding style and checkpatch fixes Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 01/12] w1: add SPDX identifiers Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 02/12] w1: improve code-style by adhering tp 80 columns per line limit Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 03/12] w1: add newlines after declarations Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 04/12] w1: cleanup whitespaces according to coding style document Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 05/12] w1: use octal numbers instead of macros for file mode Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 06/12] w1: do not log errors about failed memory allocations Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 07/12] w1: use __func__ for logging the function name Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 08/12] w1: improve code-style of struct declarations Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 09/12] w1: using linux instead of asm prefix for includes Steffen Vogel
2018-10-29  3:03 ` Steffen Vogel [this message]
2018-10-29  3:03 ` [PATCH v2 11/12] w1: replace non-standard %LX format-string by %llX Steffen Vogel
2018-10-29  3:03 ` [PATCH v2 12/12] w1: fix typo in comment Steffen Vogel

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=8d0079ed2b260a00bcaa906729325a4e8de66486.1540782140.git.post@steffenvogel.de \
    --to=post@steffenvogel.de \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.net \
    /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

all inboxes | Powered by JetHome®