simple c99 compiler
git clone git://
Log | Files | Refs | Submodules | README | LICENSE

commit c14d021feb8a7aaceaa959ad5d85c690299c67ee
parent 4b76f87ae0ad842c8a188c56280397c3a949e4a3
Author: Roberto E. Vargas Caballero <>
Date:   Thu,  3 Nov 2022 06:01:28 +0100

libc/stdio: Use size_t for cnt in vfprintf()

The cnt variable is used to count the number of bytes written in
every iteration of the loop and it was added to the len variable.
While the len variable was size_t cnt was an int and we were storing
things like size of a string that can have a size_t len. Also,
scc IR has a problem with abbreviations where the result type
is smaller than the original type, and this was one of this cases.

Msrc/libc/stdio/vfprintf.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libc/stdio/vfprintf.c b/src/libc/stdio/vfprintf.c @@ -99,7 +99,7 @@ numtostr(uintmax_t val, int flags, struct conv *conv, char *buf) } static void -savecnt(va_list *va, int flags, int cnt) +savecnt(va_list *va, int flags, size_t cnt) { if (flags & CHAR) *va_arg(*va, char*) = cnt; @@ -193,8 +193,8 @@ strout(char *s, size_t len, int width, int fill, FILE *restrict fp) int vfprintf(FILE * restrict fp, const char * restrict fmt, va_list va) { - int ch, n, flags, width, left, fill, cnt = 0; - size_t inc, len; + int ch, n, flags, width, left, fill; + size_t inc, len, cnt = 0; char *s; wchar_t *ws; struct conv conv;