Commit b9e64724 authored by Thomas Weißschuh's avatar Thomas Weißschuh

selftests/nolibc: make result alignment more robust

Move the check of the existing length into the function so it can't be
forgotten by the caller.

Also hardcode the padding character as only spaces are ever used.
Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
parent 54410245
...@@ -130,11 +130,17 @@ static const char *errorname(int err) ...@@ -130,11 +130,17 @@ static const char *errorname(int err)
} }
} }
static void putcharn(char c, size_t n) static void align_result(size_t llen)
{ {
char buf[64]; const size_t align = 64;
char buf[align];
size_t n;
memset(buf, c, n); if (llen >= align)
return;
n = align - llen;
memset(buf, ' ', n);
buf[n] = '\0'; buf[n] = '\0';
fputs(buf, stdout); fputs(buf, stdout);
} }
...@@ -156,8 +162,7 @@ static void result(int llen, enum RESULT r) ...@@ -156,8 +162,7 @@ static void result(int llen, enum RESULT r)
else else
msg = " [FAIL]"; msg = " [FAIL]";
if (llen < 64) align_result(llen);
putcharn(' ', 64 - llen);
puts(msg); puts(msg);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment