[PATCH 2/2] progressbar: add TOSTRING macro

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sat Oct 20 06:48:46 EDT 2012


On 08:51 Sat 20 Oct     , Alexander Aring wrote:
> Add TOSTRING macro in common.h and use it for
> HASH_PER_LINE in printf format string of
> function init_progression_bar.
> 
> Signed-off-by: Alexander Aring <alex.aring at gmail.com>
> ---
>  include/common.h    | 5 +++++
>  lib/show_progress.c | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/include/common.h b/include/common.h
> index c1f44b4..ffdfcd9 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -256,4 +256,9 @@ static inline void barebox_banner(void) {}
>  		(__x < 0) ? -__x : __x;         \
>  	})
>  
> +/* Convert a number define to
> + * const char* with concat */
> +#define STRINGIFY(x) #x
> +#define TOSTRING(x) STRINGIFY(x)
> +
>  #endif	/* __COMMON_H_ */
> diff --git a/lib/show_progress.c b/lib/show_progress.c
> index d958a44..eca7e1e 100644
> --- a/lib/show_progress.c
> +++ b/lib/show_progress.c
> @@ -56,7 +56,7 @@ void init_progression_bar(int max)
>  	progress_max = max;
>  	spin = 0;
>  	if (progress_max)
> -		printf("\t[%65s]\r\t[", "");
> +		printf("\t[%"TOSTRING(HASHES_PER_LINE)"s]\r\t[", "");
no we have __stringify

Best Regards,
J.
>  	else
>  		printf("\t");
>  }
> -- 
> 1.7.12.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox



More information about the barebox mailing list