Patchwork [RESUBMIT] lib: fwts_fileio.c: remove unnecessary variable len

login
register
mail settings
Submitter Colin King
Date April 11, 2012, 8:13 a.m.
Message ID <1334132026-14470-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/151740/
State Accepted
Headers show

Comments

Colin King - April 11, 2012, 8:13 a.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_fileio.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Keng-Yu Lin - April 11, 2012, 8:18 a.m.
On Wed, Apr 11, 2012 at 4:13 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_fileio.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_fileio.c b/src/lib/src/fwts_fileio.c
> index c0a6f15..b3131e3 100644
> --- a/src/lib/src/fwts_fileio.c
> +++ b/src/lib/src/fwts_fileio.c
> @@ -37,8 +37,7 @@ fwts_list *fwts_file_read(FILE *fp)
>                return NULL;
>
>        while (fgets(buffer, sizeof(buffer), fp) != NULL) {
> -               int len = strlen(buffer);
> -               buffer[len-1] = '\0';   /* Chop off "\n" */
> +               buffer[strlen(buffer) - 1] = '\0';      /* Chop off "\n" */
>                fwts_text_list_append(list, buffer);
>        }
>
> --
> 1.7.9.1
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - April 11, 2012, 8:19 a.m.
On 04/11/2012 04:13 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_fileio.c |    3 +--
>   1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_fileio.c b/src/lib/src/fwts_fileio.c
> index c0a6f15..b3131e3 100644
> --- a/src/lib/src/fwts_fileio.c
> +++ b/src/lib/src/fwts_fileio.c
> @@ -37,8 +37,7 @@ fwts_list *fwts_file_read(FILE *fp)
>   		return NULL;
>
>   	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
> -		int len = strlen(buffer);
> -		buffer[len-1] = '\0';	/* Chop off "\n" */
> +		buffer[strlen(buffer) - 1] = '\0';	/* Chop off "\n" */
>   		fwts_text_list_append(list, buffer);
>   	}
>
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/lib/src/fwts_fileio.c b/src/lib/src/fwts_fileio.c
index c0a6f15..b3131e3 100644
--- a/src/lib/src/fwts_fileio.c
+++ b/src/lib/src/fwts_fileio.c
@@ -37,8 +37,7 @@  fwts_list *fwts_file_read(FILE *fp)
 		return NULL;
 
 	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-		int len = strlen(buffer);
-		buffer[len-1] = '\0';	/* Chop off "\n" */
+		buffer[strlen(buffer) - 1] = '\0';	/* Chop off "\n" */
 		fwts_text_list_append(list, buffer);
 	}