newlib: fix uninitialized character count being used when printing float without "_printf_float" being linked
Commit Message
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.
---
newlib/libc/machine/msp430/tiny-printf.c | 1 +
newlib/libc/stdio/nano-vfprintf.c | 1 +
2 files changed, 2 insertions(+)
Comments
On Mar 13 19:23, Igor Petrov wrote:
> 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.
>
> ---
> newlib/libc/machine/msp430/tiny-printf.c | 1 +
> newlib/libc/stdio/nano-vfprintf.c | 1 +
> 2 files changed, 2 insertions(+)
Pushed.
Thanks,
Corinna
@@ -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);
@@ -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);