Patchwork [1/3] lib: fwts_test: calloc being called with args swapped

login
register
mail settings
Submitter Colin King
Date Nov. 16, 2012, 8:32 a.m.
Message ID <1353054776-4856-2-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/199515/
State Accepted
Headers show

Comments

Colin King - Nov. 16, 2012, 8:32 a.m.
From: Colin Ian King <colin.king@canonical.com>

Fix calloc call in fwts_list_append, args were swapped which
still works but we should fix this so we are allocating one
fwts_list_link rather than sizeof(fwts_list_link) number of
bytes.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_list.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - Nov. 22, 2012, 3 a.m.
On 11/16/2012 04:32 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Fix calloc call in fwts_list_append, args were swapped which
> still works but we should fix this so we are allocating one
> fwts_list_link rather than sizeof(fwts_list_link) number of
> bytes.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_list.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_list.c b/src/lib/src/fwts_list.c
> index e26b2cb..935910b 100644
> --- a/src/lib/src/fwts_list.c
> +++ b/src/lib/src/fwts_list.c
> @@ -121,7 +121,7 @@ fwts_list_link *fwts_list_append(fwts_list *list, void *data)
>   	if (list == NULL)
>   		return NULL;
>
> -	if ((link = calloc(sizeof(fwts_list_link),1)) == NULL)
> +	if ((link = calloc(1,sizeof(fwts_list_link))) == NULL)
>   		return NULL;
>
>   	link->data = data;
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Nov. 22, 2012, 6:07 a.m.
On Fri, Nov 16, 2012 at 4:32 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Fix calloc call in fwts_list_append, args were swapped which
> still works but we should fix this so we are allocating one
> fwts_list_link rather than sizeof(fwts_list_link) number of
> bytes.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_list.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_list.c b/src/lib/src/fwts_list.c
> index e26b2cb..935910b 100644
> --- a/src/lib/src/fwts_list.c
> +++ b/src/lib/src/fwts_list.c
> @@ -121,7 +121,7 @@ fwts_list_link *fwts_list_append(fwts_list *list, void *data)
>         if (list == NULL)
>                 return NULL;
>
> -       if ((link = calloc(sizeof(fwts_list_link),1)) == NULL)
> +       if ((link = calloc(1,sizeof(fwts_list_link))) == NULL)
>                 return NULL;
>
>         link->data = data;
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_list.c b/src/lib/src/fwts_list.c
index e26b2cb..935910b 100644
--- a/src/lib/src/fwts_list.c
+++ b/src/lib/src/fwts_list.c
@@ -121,7 +121,7 @@  fwts_list_link *fwts_list_append(fwts_list *list, void *data)
 	if (list == NULL)
 		return NULL;
 
-	if ((link = calloc(sizeof(fwts_list_link),1)) == NULL)
+	if ((link = calloc(1,sizeof(fwts_list_link))) == NULL)
 		return NULL;
 
 	link->data = data;