This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On 12/25/2017 07:39 AM, Alexander Fedotov wrote:
> Hi
>
> I'm experienced a strange printf() for float variables behaviour with
> Nano version while regular is fine. It just prins out a garbage (even
> with enabled -u _printf_float). After some digging I've managed to
> track down issue until this line:
>
> n = _printf_float (data, &prt_data, fp, pfunc, &ap);
>
>
> Moreover there are number of warnings also in build log:
>
> src_newlib/newlib/libc/stdio/nano-vfprintf.c -o lib_a-nano-svfprintf.o
> ../../../../../../src_newlib/newlib/libc/stdio/nano-vfprintf.c: In
> function '_svfprintf_r':
> ../../../../../../src_newlib/newlib/libc/stdio/nano-vfprintf.c:645:55:
> warning: passing argument 5 of '_printf_float' from incompatible
> pointer type
> n = _printf_float (data, &prt_data, fp, pfunc, &ap);
> ^
One possibility for a workaround that I've seen used in other projects
is to do a va_copy() and pass a pointer to the copy rather than the
original ap passed in as a parameter. Here's a thread from the qemu list:
https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg00605.html
https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg00171.html
and where the va_copy() code is used in practice:
https://git.qemu.org/?p=qemu.git;a=blob;f=tests/libqtest.c;h=0ec8af292;hb=2077fef9#l472
in order to call a function taking va_list *.
472 void qmp_fd_sendv(int fd, const char *fmt, va_list ap)
473 {
474 va_list ap_copy;
...
484
485 /* Going through qobject ensures we escape strings properly.
486 * This seemingly unnecessary copy is required in case va_list
487 * is an array type.
488 */
489 va_copy(ap_copy, ap);
490 qobj = qobject_from_jsonv(fmt, &ap_copy, &error_abort);
491 va_end(ap_copy);
492
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |