ACK: [PATCH 28/46] lib: fwts_dump: replace asctime with strftime

IvanHu ivan.hu at canonical.com
Thu Jan 15 07:35:35 UTC 2015


On 01/14/2015 03:04 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> cppcheck is picking up some minor style issues which can
> be easily fixed:
>
> [src/lib/src/fwts_dump.c:203]:
> 	(style) Obsolete function 'asctime' called. It is
> 	recommended to use the function 'strftime' instead.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/lib/src/fwts_dump.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/src/fwts_dump.c b/src/lib/src/fwts_dump.c
> index 33156c0..0023aea 100644
> --- a/src/lib/src/fwts_dump.c
> +++ b/src/lib/src/fwts_dump.c
> @@ -193,16 +193,14 @@ static int dump_readme(void)
>   {
>   	time_t now = time(NULL);
>   	struct tm *tm = localtime(&now);
> +	char *str, buf[64];
>   	FILE *fp;
> -	char *str;
> -	int len;
>
>   	if ((fp = fopen("README.txt", "w")) == NULL)
>   		return FWTS_ERROR;
>
> -	str = asctime(tm);
> -	len = strlen(str) - 1;
> -	fprintf(fp, "This is output captured by fwts on %*.*s.\n\n", len, len, str);
> +	(void)strftime(buf, sizeof(buf), "%a %b %e %T %Y", tm);
> +	fprintf(fp, "This is output captured by fwts on %s.\n\n", buf);
>
>   	fwts_framework_show_version(fp, "fwts");
>
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list