Patchwork lib: fwts_klog: remove redundant free()

login
register
mail settings
Submitter Colin King
Date March 8, 2012, 12:48 p.m.
Message ID <1331210892-27643-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/145517/
State Accepted
Headers show

Comments

Colin King - March 8, 2012, 12:48 p.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_klog.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
Alex Hung - March 9, 2012, 1:58 a.m.
On 03/08/2012 08:48 PM, Colin King wrote:
> From: Colin Ian King<colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king@canonical.com>
> ---
>   src/lib/src/fwts_klog.c |    4 +---
>   1 files changed, 1 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
> index 39e8183..7b7fb41 100644
> --- a/src/lib/src/fwts_klog.c
> +++ b/src/lib/src/fwts_klog.c
> @@ -66,10 +66,8 @@ fwts_list *fwts_klog_read(void)
>   	if ((len = klogctl(10, NULL, 0))<  0)
>   		return NULL;
>
> -	if ((buffer = calloc(1, len)) == NULL) {
> -		free(buffer);
> +	if ((buffer = calloc(1, len)) == NULL)
>   		return NULL;
> -	}
>   	
>   	if (klogctl(3, buffer, len)<  0) {
>   		free(buffer);
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - March 9, 2012, 5:38 a.m.
On Thu, Mar 8, 2012 at 8:48 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_klog.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
> index 39e8183..7b7fb41 100644
> --- a/src/lib/src/fwts_klog.c
> +++ b/src/lib/src/fwts_klog.c
> @@ -66,10 +66,8 @@ fwts_list *fwts_klog_read(void)
>        if ((len = klogctl(10, NULL, 0)) < 0)
>                return NULL;
>
> -       if ((buffer = calloc(1, len)) == NULL) {
> -               free(buffer);
> +       if ((buffer = calloc(1, len)) == NULL)
>                return NULL;
> -       }
>
>        if (klogctl(3, buffer, len) < 0) {
>                free(buffer);
> --
> 1.7.9
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
index 39e8183..7b7fb41 100644
--- a/src/lib/src/fwts_klog.c
+++ b/src/lib/src/fwts_klog.c
@@ -66,10 +66,8 @@  fwts_list *fwts_klog_read(void)
 	if ((len = klogctl(10, NULL, 0)) < 0)
 		return NULL;
 
-	if ((buffer = calloc(1, len)) == NULL) {
-		free(buffer);
+	if ((buffer = calloc(1, len)) == NULL)
 		return NULL;
-	}
 	
 	if (klogctl(3, buffer, len) < 0) {
 		free(buffer);