Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1623913 > unrolled thread

[PATCH 1/2] regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-04-14 23:10 +0200
Last post2017-04-15 19:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/2] regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-14 23:10 +0200
    Re: [PATCH 1/2] regulator: s2mps11: Use kcalloc() in  s2mps11_pmic_probe() Krzysztof Kozlowski <krzk@kernel.org> - 2017-04-15 12:50 +0200
      Re: regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-15 19:30 +0200

#1623913 — [PATCH 1/2] regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-14 23:10 +0200
Subject[PATCH 1/2] regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe()
Message-ID<twgDE-69I-5@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 14 Apr 2017 22:00:35 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/regulator/s2mps11.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 7726b874e539..b4e588cce03d 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -1162,7 +1162,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
 		}
 	}
 
-	rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL);
+	rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL);
 	if (!rdata)
 		return -ENOMEM;
 
-- 
2.12.2

[toc] | [next] | [standalone]


#1624044 — Re: [PATCH 1/2] regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe()

FromKrzysztof Kozlowski <krzk@kernel.org>
Date2017-04-15 12:50 +0200
SubjectRe: [PATCH 1/2] regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe()
Message-ID<twtrc-5tU-5@gated-at.bofh.it>
In reply to#1623913
On Fri, Apr 14, 2017 at 11:01:25PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 14 Apr 2017 22:00:35 +0200
> 
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kcalloc".
> 
> This issue was detected by using the Coccinelle software.

Unfortunately you write mostly cryptic commit messages. This does not
answer for the main question - why this change is needed. Code looks
okay, but you should explain in simple words why this is needed.

Best regards,
Krzysztof

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/regulator/s2mps11.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
> index 7726b874e539..b4e588cce03d 100644
> --- a/drivers/regulator/s2mps11.c
> +++ b/drivers/regulator/s2mps11.c
> @@ -1162,7 +1162,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL);
> +	rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL);
>  	if (!rdata)
>  		return -ENOMEM;
>  
> -- 
> 2.12.2
> 

[toc] | [prev] | [next] | [standalone]


#1624098 — Re: regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-15 19:30 +0200
SubjectRe: regulator: s2mps11: Use kcalloc() in s2mps11_pmic_probe()
Message-ID<twzGi-YI-7@gated-at.bofh.it>
In reply to#1624044
>> A multiplication for the size determination of a memory allocation
>> indicated that an array data structure should be processed.
>> Thus use the corresponding function "kcalloc".
>>
>> This issue was detected by using the Coccinelle software.
> 
> Unfortunately you write mostly cryptic commit messages.

Thanks for your feedback.


> This does not answer for the main question - why this change is needed.

My update suggestion affects an aspect for the coding style.


> Code looks okay,

There can be different opinions about related implementation details.


> but you should explain in simple words why this is needed.

Do you find the following wording from the script “checkpatch.pl”
better to understand?

WARNING: Prefer kcalloc over kzalloc with multiply


Regards,
Markus

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web