[PATCH 2/2] progressbar: add TOSTRING macro

Alexander Aring alex.aring at googlemail.com
Sat Oct 20 02:51:05 EDT 2012


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[", "");
 	else
 		printf("\t");
 }
-- 
1.7.12.4




More information about the barebox mailing list