diff mbox

[U-Boot,01/20] tiny-printf: Tidy up a few nits

Message ID 1463256198-3829-2-git-send-email-sjg@chromium.org
State Accepted
Commit 1fb67608b309bd7f49842fbdfb1dc2b18a250965
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass May 14, 2016, 8:02 p.m. UTC
- Rename 'w' to 'width' to make it more obvious what it is used for
- Use bool and int types instead of char to avoid register-masking on
32-bit machines

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/tiny-printf.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Stefan Roese May 16, 2016, 9:29 a.m. UTC | #1
On 14.05.2016 22:02, Simon Glass wrote:
> - Rename 'w' to 'width' to make it more obvious what it is used for
> - Use bool and int types instead of char to avoid register-masking on
> 32-bit machines
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
Simon Glass May 27, 2016, 4:24 p.m. UTC | #2
On 16 May 2016 at 03:29, Stefan Roese <sr@denx.de> wrote:
>
> On 14.05.2016 22:02, Simon Glass wrote:
>>
>> - Rename 'w' to 'width' to make it more obvious what it is used for
>> - Use bool and int types instead of char to avoid register-masking on
>> 32-bit machines
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
>
> Reviewed-by: Stefan Roese <sr@denx.de>
>
> Thanks,
> Stefan

Applied to u-boot-dm.
diff mbox

Patch

diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index a06abed..fbd5368 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -52,8 +52,8 @@  int vprintf(const char *fmt, va_list va)
 		if (ch != '%') {
 			putc(ch);
 		} else {
-			char lz = 0;
-			char w = 0;
+			bool lz = false;
+			int width = 0;
 
 			ch = *(fmt++);
 			if (ch == '0') {
@@ -62,9 +62,9 @@  int vprintf(const char *fmt, va_list va)
 			}
 
 			if (ch >= '0' && ch <= '9') {
-				w = 0;
+				width = 0;
 				while (ch >= '0' && ch <= '9') {
-					w = (w * 10) + ch - '0';
+					width = (width * 10) + ch - '0';
 					ch = *fmt++;
 				}
 			}
@@ -73,7 +73,7 @@  int vprintf(const char *fmt, va_list va)
 			zs = 0;
 
 			switch (ch) {
-			case 0:
+			case '\0':
 				goto abort;
 			case 'u':
 			case 'd':
@@ -112,9 +112,9 @@  int vprintf(const char *fmt, va_list va)
 
 			*bf = 0;
 			bf = p;
-			while (*bf++ && w > 0)
-				w--;
-			while (w-- > 0)
+			while (*bf++ && width > 0)
+				width--;
+			while (width-- > 0)
 				putc(lz ? '0' : ' ');
 			if (p) {
 				while ((ch = *p++))