diff options
author | Igor Petrov <igor.petrov.dev@pm.me> | 2025-03-13 19:23:04 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2025-03-14 17:05:21 +0100 |
commit | 1409c7872f5755d0770dffaaa57aa583e64196f4 (patch) | |
tree | 896246276fd143288243b190fd9353b8e2e7359b /newlib/libc | |
parent | 0f02ac19102dd8e5c5722cac2f6069e646f0f42c (diff) | |
download | newlib-1409c7872f5755d0770dffaaa57aa583e64196f4.zip newlib-1409c7872f5755d0770dffaaa57aa583e64196f4.tar.gz newlib-1409c7872f5755d0770dffaaa57aa583e64196f4.tar.bz2 |
newlib: fix uninitialized character count being used when printing float without "_printf_float" being linked
Patch fixes wrong number of written characters being returend from 'printf'
family of functionsx when '_printf_float' is not linked (nano.specs). If user
tries to print a floating point number anyway, returned number of written
characters is not correct. For example in
printf("%d%f", 1, 1.0);
should return 1, but actaully returns 2.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/machine/msp430/tiny-printf.c | 1 | ||||
-rw-r--r-- | newlib/libc/stdio/nano-vfprintf.c | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/newlib/libc/machine/msp430/tiny-printf.c b/newlib/libc/machine/msp430/tiny-printf.c index f2412a0..b5ad528 100644 --- a/newlib/libc/machine/msp430/tiny-printf.c +++ b/newlib/libc/machine/msp430/tiny-printf.c @@ -237,6 +237,7 @@ __tiny_vfprintf_r (struct _reent *data, GET_ARG (N, ap_copy, _LONG_DOUBLE); else GET_ARG (N, ap_copy, double); + n = 0; } else n = _printf_float (data, &prt_data, fp, pfunc, &ap_copy); diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-vfprintf.c index 0d42a94..bdcc9b2 100644 --- a/newlib/libc/stdio/nano-vfprintf.c +++ b/newlib/libc/stdio/nano-vfprintf.c @@ -627,6 +627,7 @@ _VFPRINTF_R (struct _reent *data, GET_ARG (N, ap_copy, _LONG_DOUBLE); else GET_ARG (N, ap_copy, double); + n = 0; } else n = _printf_float (data, &prt_data, fp, pfunc, &ap_copy); |