[PATCH] lib: fwts_fileio.c: use size_t instead of int

Alex Hung alex.hung at canonical.com
Wed Apr 11 02:19:52 UTC 2012


On 04/10/2012 10:39 PM, Colin King wrote:
> From: Colin Ian King<colin.king at canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king at canonical.com>
> ---
>   src/lib/src/fwts_fileio.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/lib/src/fwts_fileio.c b/src/lib/src/fwts_fileio.c
> index c0a6f15..66e399f 100644
> --- a/src/lib/src/fwts_fileio.c
> +++ b/src/lib/src/fwts_fileio.c
> @@ -37,7 +37,7 @@ fwts_list *fwts_file_read(FILE *fp)
>   		return NULL;
>
>   	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
> -		int len = strlen(buffer);
> +		size_t len = strlen(buffer);
>   		buffer[len-1] = '\0';	/* Chop off "\n" */
>   		fwts_text_list_append(list, buffer);
>   	}
The variable len is only used once.
Will it be better to change
                 int len = strlen(buffer);
                 buffer[len-1] = '\0';   /* Chop off "\n" */
to
                 buffer[strlen(buffer) - 1] = '\0';   /* Chop off "\n" */
so we don't need to worry about the type of len?





More information about the fwts-devel mailing list