Patchwork [2/3] cpu: maxfreq: use number of cpus as number of items in calloc()

login
register
mail settings
Submitter Colin King
Date April 24, 2013, 9:25 a.m.
Message ID <1366795523-4538-3-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/239094/
State Accepted
Headers show

Comments

Colin King - April 24, 2013, 9:25 a.m.
From: Colin Ian King <colin.king@canonical.com>

Use number of cpus as number if items in calloc().

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/cpu/maxfreq/maxfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - April 25, 2013, 5:41 a.m.
On 04/24/2013 05:25 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Use number of cpus as number if items in calloc().
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/maxfreq/maxfreq.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
> index a91ec30..7678333 100644
> --- a/src/cpu/maxfreq/maxfreq.c
> +++ b/src/cpu/maxfreq/maxfreq.c
> @@ -79,7 +79,7 @@ static int maxfreq_test1(fwts_framework *fw)
>   			cpus++;
>   	}
>
> -	if ((cpufreq = calloc(1, sizeof(int)*cpus)) == NULL) {
> +	if ((cpufreq = calloc(cpus, sizeof(int))) == NULL) {
>   		fwts_log_error(fw, "Cannot create cpu frequency array.");
>   		return FWTS_ERROR;
>   	}
>
Acked-by: Alex Hung <alex.hung@canonical.com
Keng-Yu Lin - April 26, 2013, 2:45 a.m.
On Wed, Apr 24, 2013 at 5:25 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Use number of cpus as number if items in calloc().
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/cpu/maxfreq/maxfreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
> index a91ec30..7678333 100644
> --- a/src/cpu/maxfreq/maxfreq.c
> +++ b/src/cpu/maxfreq/maxfreq.c
> @@ -79,7 +79,7 @@ static int maxfreq_test1(fwts_framework *fw)
>                         cpus++;
>         }
>
> -       if ((cpufreq = calloc(1, sizeof(int)*cpus)) == NULL) {
> +       if ((cpufreq = calloc(cpus, sizeof(int))) == NULL) {
>                 fwts_log_error(fw, "Cannot create cpu frequency array.");
>                 return FWTS_ERROR;
>         }
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
index a91ec30..7678333 100644
--- a/src/cpu/maxfreq/maxfreq.c
+++ b/src/cpu/maxfreq/maxfreq.c
@@ -79,7 +79,7 @@  static int maxfreq_test1(fwts_framework *fw)
 			cpus++;
 	}
 
-	if ((cpufreq = calloc(1, sizeof(int)*cpus)) == NULL) {
+	if ((cpufreq = calloc(cpus, sizeof(int))) == NULL) {
 		fwts_log_error(fw, "Cannot create cpu frequency array.");
 		return FWTS_ERROR;
 	}