Patchwork [3/3] utilities: kernelscan: swap calloc arguments in unget_next()

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

Comments

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

In unget_next() we should be allocating 1 lot of get_stack sized
memory rather than get_stack sized lots of bytes. Not that it makes
much difference, but fix the order anyhow.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/utilities/kernelscan.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - Nov. 22, 2012, 3:01 a.m.
On 11/16/2012 04:32 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In unget_next() we should be allocating 1 lot of get_stack sized
> memory rather than get_stack sized lots of bytes. Not that it makes
> much difference, but fix the order anyhow.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/utilities/kernelscan.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 7b12f83..d966f03 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -147,7 +147,7 @@ static void unget_next(parser *p, int ch)
>   {
>   	get_stack *new;
>
> -	if ((new = calloc(sizeof(get_stack), 1)) == NULL) {
> +	if ((new = calloc(1, sizeof(get_stack))) == NULL) {
>   		fprintf(stderr, "unget_next: Out of memory!\n");
>   		exit(EXIT_FAILURE);
>   	}
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Nov. 22, 2012, 6:09 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>
>
> In unget_next() we should be allocating 1 lot of get_stack sized
> memory rather than get_stack sized lots of bytes. Not that it makes
> much difference, but fix the order anyhow.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/utilities/kernelscan.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 7b12f83..d966f03 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -147,7 +147,7 @@ static void unget_next(parser *p, int ch)
>  {
>         get_stack *new;
>
> -       if ((new = calloc(sizeof(get_stack), 1)) == NULL) {
> +       if ((new = calloc(1, sizeof(get_stack))) == NULL) {
>                 fprintf(stderr, "unget_next: Out of memory!\n");
>                 exit(EXIT_FAILURE);
>         }
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
index 7b12f83..d966f03 100644
--- a/src/utilities/kernelscan.c
+++ b/src/utilities/kernelscan.c
@@ -147,7 +147,7 @@  static void unget_next(parser *p, int ch)
 {
 	get_stack *new;
 
-	if ((new = calloc(sizeof(get_stack), 1)) == NULL) {
+	if ((new = calloc(1, sizeof(get_stack))) == NULL) {
 		fprintf(stderr, "unget_next: Out of memory!\n");
 		exit(EXIT_FAILURE);
 	}