mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl/libc: Fix printing zeros in vsnprintf
Printing the number zero (e.g. printf("%u", 0)) currently only gives you
an empty string. This is because the while-do loop to map the number to a
string is only entered when the value is 'true', i.e. non-zero. Fix this
by using do-while instead.
Fixes: 6fe9e6c ("zipl/libc: Introduce vsnprintf")
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reported-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
1b65b23b43
commit
454f1427d3
@@ -266,10 +266,10 @@ static char *number(char *buf, char *end, unsigned long val,
|
||||
|
||||
/* prepare string in reverse order */
|
||||
len = 0;
|
||||
while (val) {
|
||||
do {
|
||||
tmp[len++] = vec[val % spec->base];
|
||||
val /= spec->base;
|
||||
}
|
||||
} while (val);
|
||||
|
||||
if (len > precision)
|
||||
precision = len;
|
||||
|
||||
Reference in New Issue
Block a user