Skip to contentSkip to conversation

progressbar: use __stringify in format string

PATCH In review Alexander Aring 2 participants 2 messages Oct 20, 2012 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 progressbar: use __stringify in format string

Use stringify in format string for HASH_PER_LINE.

---
 lib/show_progress.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/show_progress.c +4 -1
index d958a44..a43b4c9 100644
@@ -20,6 +20,7 @@
 #include <common.h>
 #include <progress.h>
 #include <asm-generic/div64.h>
+#include <linux/stringify.h>
 
 #define HASHES_PER_LINE	65
 
@@ -56,7 +57,9 @@ void init_progression_bar(int max)
 	progress_max = max;
 	spin = 0;
 	if (progress_max)
-		printf("\t[%65s]\r\t[", "");
+		printf("\t[%"
+				__stringify(HASHES_PER_LINE)
+				"s]\r\t[", "");
 	else
 		printf("\t");
 }
Signature · 7 lines
1.7.12.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 20 lines · Alexander Aring

Use stringify in format string for HASH_PER_LINE.

---
 lib/show_progress.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/show_progress.c +1 -0
index d958a44..a43b4c9 100644
@@ -20,6 +20,7 @@
 #include <common.h>
 #include <progress.h>
 #include <asm-generic/div64.h>
+#include <linux/stringify.h>
 
 #define HASHES_PER_LINE	65
 

lib/show_progress.c void init_progression_bar(int max) · line 62

Quoted 7 lines
lib/show_progress.c +3 -1
@@ -56,7 +57,9 @@ void init_progression_bar(int max)
 	progress_max = max;
 	spin = 0;
 	if (progress_max)
-		printf("\t[%65s]\r\t[", "");
+		printf("\t[%"
+				__stringify(HASHES_PER_LINE)
+				"s]\r\t[", "");

online is more readable

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox