On 10/12/2017 09:12 AM, Pino Toscano wrote:
> On Wednesday, 11 October 2017 17:23:45 CEST Richard W.M. Jones wrote:
>> +static int
>> +mexp_vprintf (mexp_h *h, int password, const char *fs, va_list args)
>> {
>> - va_list args;
>> char *msg;
>> int len;
>> size_t n;
>> ssize_t r;
>> char *p;
>>
>> - va_start (args, fs);
>> len = vasprintf (&msg, fs, args);
>> - va_end (args);
>
> Due to the nature of va_list (whose implementation greatly differs per
> architecture -- from a pointer, to a list of pointers, to structs, etc),
> I think that here you need to copy the va_list using va_copy(), and
> pass the copy to vasprintf.Not needed here. If you take va_list as a parameter and do nothing further with it other than to forward on to another function that takes va_list, you are fine. If you use va_list* anywhere, or if you want to do partial processing on args before handing the rest of args to another function, then you are indeed correct that a va_copy makes life easier. > > I cannot find a better reference, but > https://stackoverflow.com/questions/3369588/pass-va-list-or-pointer-to-va-list > has a piece of advice on that. Here's a recent explanation on the qemu list, where va_list* is involved, and thus the va_copy is necessary: https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg00171.html -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
