From: elfring@users.sourceforge.net (SF Markus Elfring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations
Date: Fri, 15 Sep 2017 19:29:42 +0200 [thread overview]
Message-ID: <f4e400ea-9660-05cd-3194-cdf2495a2376@users.sourceforge.net> (raw)
In-Reply-To: <730b535e-39a5-2c2b-f463-e76da967a723@users.sourceforge.net>
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
next prev parent reply other threads:[~2017-09-15 17:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 17:27 [PATCH 0/2] [media] STM32-DCMI: Adjustments for three function implementations SF Markus Elfring
2017-09-15 17:28 ` [PATCH 1/2] [media] stm32-dcmi: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-09-15 17:29 ` SF Markus Elfring [this message]
2017-09-15 18:16 ` [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations Joe Perches
2017-09-15 18:54 ` 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=f4e400ea-9660-05cd-3194-cdf2495a2376@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).