lkml.org 
[lkml]   [2017]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/2] [media] stm32-dcmi: Improve four size determinations
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 15 Sep 2017 18:48:14 +0200

Replace the specification of data types 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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/platform/stm32/stm32-dcmi.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index df12d10bd230..c4895cc95cc1 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1372,9 +1372,8 @@ static int dcmi_formats_init(struct stm32_dcmi *dcmi)
dcmi->sd_formats = devm_kcalloc(dcmi->dev,
- num_fmts, sizeof(struct dcmi_format *),
+ num_fmts, sizeof(*dcmi->sd_formats),
GFP_KERNEL);
if (!dcmi->sd_formats)
return -ENOMEM;

- memcpy(dcmi->sd_formats, sd_fmts,
- num_fmts * sizeof(struct dcmi_format *));
+ memcpy(dcmi->sd_formats, sd_fmts, num_fmts * sizeof(*dcmi->sd_formats));
dcmi->sd_format = dcmi->sd_formats[0];
@@ -1406,3 +1405,3 @@ static int dcmi_framesizes_init(struct stm32_dcmi *dcmi)
dcmi->sd_framesizes = devm_kcalloc(dcmi->dev, num_fsize,
- sizeof(struct dcmi_framesize),
+ sizeof(*dcmi->sd_framesizes),
GFP_KERNEL);
@@ -1570,5 +1569,5 @@ static int dcmi_probe(struct platform_device *pdev)
return -ENODEV;
}

- dcmi = devm_kzalloc(&pdev->dev, sizeof(struct stm32_dcmi), GFP_KERNEL);
+ dcmi = devm_kzalloc(&pdev->dev, sizeof(*dcmi), GFP_KERNEL);
if (!dcmi)
--
2.14.1
\
 
 \ /
  Last update: 2017-09-15 19:31    [W:0.074 / U:0.208 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site