lkml.org 
[lkml]   [2018]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH v2 05/17 1/2] mfd: sm501: Improve a size determination in two functions
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 8 Mar 2018 14:05:41 +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>
---

v2:
Lee Jones requested a different source code layout for this transformation.
The change was rebased on source files from Linux next-20180308.

drivers/mfd/sm501.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 7298d6b571a1..4f4957ea8fa3 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1383,7 +1383,7 @@ static int sm501_plat_probe(struct platform_device *dev)
struct sm501_devdata *sm;
int ret;

- sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);
+ sm = kzalloc(sizeof(*sm), GFP_KERNEL);
if (sm == NULL) {
ret = -ENOMEM;
goto err1;
@@ -1572,7 +1572,7 @@ static int sm501_pci_probe(struct pci_dev *dev,
struct sm501_devdata *sm;
int err;

- sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);
+ sm = kzalloc(sizeof(*sm), GFP_KERNEL);
if (sm == NULL) {
err = -ENOMEM;
goto err1;
--
2.16.2
\
 
 \ /
  Last update: 2018-03-09 17:13    [W:0.078 / U:18.552 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site