mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kernel-janitors@vger.kernel.org, Lee Jones <lee.jones@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] mfd/sm501: Improve a size determination in two functions
Date: Mon, 15 Jan 2018 16:15:36 +0100	[thread overview]
Message-ID: <3b264527-b43f-b6aa-0570-c6d48ed24679@users.sourceforge.net> (raw)
In-Reply-To: <f292e2f3-2471-4ea0-3a02-349e6c10ff03@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 15 Jan 2018 15:47:03 +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>
---
 drivers/mfd/sm501.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 7298d6b571a1..d5ab3481794a 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1380,10 +1380,9 @@ static int sm501_init_dev(struct sm501_devdata *sm)
 
 static int sm501_plat_probe(struct platform_device *dev)
 {
-	struct sm501_devdata *sm;
 	int ret;
+	struct sm501_devdata *sm = kzalloc(sizeof(*sm), GFP_KERNEL);
 
-	sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);
 	if (sm == NULL) {
 		ret = -ENOMEM;
 		goto err1;
@@ -1569,10 +1568,9 @@ static struct sm501_platdata sm501_pci_platdata = {
 static int sm501_pci_probe(struct pci_dev *dev,
 				     const struct pci_device_id *id)
 {
-	struct sm501_devdata *sm;
 	int err;
+	struct sm501_devdata *sm = kzalloc(sizeof(*sm), GFP_KERNEL);
 
-	sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);
 	if (sm == NULL) {
 		err = -ENOMEM;
 		goto err1;
-- 
2.15.1

  parent reply	other threads:[~2018-01-15 15:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 15:12 [PATCH 0/3] mfd/sm501: Adjustments for five function implementations SF Markus Elfring
2018-01-15 15:14 ` [PATCH 1/3] mfd/sm501: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2018-01-22 15:45   ` Lee Jones
2018-01-15 15:15 ` SF Markus Elfring [this message]
2018-01-22 15:47   ` [PATCH 2/3] mfd/sm501: Improve a size determination " Lee Jones
2018-01-15 15:16 ` [PATCH 3/3] mfd/sm501: Adjust 12 checks for null pointers SF Markus Elfring
2018-01-22 15:49   ` Lee Jones
2018-01-23 13:04     ` Lee Jones
2018-01-23 13:34       ` [3/3] " SF Markus Elfring

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=3b264527-b43f-b6aa-0570-c6d48ed24679@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®