* [PATCH 0/2] [media] STM32-DCMI: Adjustments for three function implementations @ 2017-09-15 17:27 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 ` [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations SF Markus Elfring 0 siblings, 2 replies; 5+ messages in thread From: SF Markus Elfring @ 2017-09-15 17:27 UTC (permalink / raw) To: linux-arm-kernel From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 15 Sep 2017 19:01:23 +0200 Two update suggestions were taken into account from static source code analysis. Markus Elfring (2): Delete an error message for a failed memory allocation in two functions Improve four size determinations drivers/media/platform/stm32/stm32-dcmi.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) -- 2.14.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] [media] stm32-dcmi: Delete an error message for a failed memory allocation in two functions 2017-09-15 17:27 [PATCH 0/2] [media] STM32-DCMI: Adjustments for three function implementations SF Markus Elfring @ 2017-09-15 17:28 ` SF Markus Elfring 2017-09-15 17:29 ` [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations SF Markus Elfring 1 sibling, 0 replies; 5+ messages in thread From: SF Markus Elfring @ 2017-09-15 17:28 UTC (permalink / raw) To: linux-arm-kernel From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 15 Sep 2017 18:38:25 +0200 Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/media/platform/stm32/stm32-dcmi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 35ba6f211b79..df12d10bd230 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -1374,6 +1374,4 @@ static int dcmi_formats_init(struct stm32_dcmi *dcmi) GFP_KERNEL); - if (!dcmi->sd_formats) { - dev_err(dcmi->dev, "Could not allocate memory\n"); + if (!dcmi->sd_formats) return -ENOMEM; - } @@ -1410,7 +1408,5 @@ static int dcmi_framesizes_init(struct stm32_dcmi *dcmi) GFP_KERNEL); - if (!dcmi->sd_framesizes) { - dev_err(dcmi->dev, "Could not allocate memory\n"); + if (!dcmi->sd_framesizes) return -ENOMEM; - } /* Fill array with sensor supported framesizes */ -- 2.14.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations 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 2017-09-15 18:16 ` Joe Perches 1 sibling, 1 reply; 5+ messages in thread From: SF Markus Elfring @ 2017-09-15 17:29 UTC (permalink / raw) To: linux-arm-kernel 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations 2017-09-15 17:29 ` [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations SF Markus Elfring @ 2017-09-15 18:16 ` Joe Perches 2017-09-15 18:54 ` SF Markus Elfring 0 siblings, 1 reply; 5+ messages in thread From: Joe Perches @ 2017-09-15 18:16 UTC (permalink / raw) To: linux-arm-kernel On Fri, 2017-09-15 at 19:29 +0200, SF Markus Elfring wrote: > diff --git 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)); devm_kmemdup ^ permalink raw reply [flat|nested] 5+ messages in thread
* [media] stm32-dcmi: Improve four size determinations 2017-09-15 18:16 ` Joe Perches @ 2017-09-15 18:54 ` SF Markus Elfring 0 siblings, 0 replies; 5+ messages in thread From: SF Markus Elfring @ 2017-09-15 18:54 UTC (permalink / raw) To: linux-arm-kernel >> + memcpy(dcmi->sd_formats, sd_fmts, num_fmts * sizeof(*dcmi->sd_formats)); > > devm_kmemdup Are function variants provided which handle memory duplications for arrays explicitly? Regards, Markus ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-15 18:54 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH 2/2] [media] stm32-dcmi: Improve four size determinations SF Markus Elfring 2017-09-15 18:16 ` Joe Perches 2017-09-15 18:54 ` SF Markus Elfring
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).