On 03/10/2014 01:10 PM, Stefan Berger wrote:
Eric Blake <eblake(a)redhat.com> wrote on 03/10/2014 02:09:58
PM:
>> +/* Initialize an array of file descriptors to -1 */
>> +# define VIR_INIT_N_FD(ptr, count) \
>> + vir_init_n_int(ptr, count, -1)
>
> Could also be spelled:
>
> memset(ptr, -1, sizeof(*ptr) * count))
>
> which goes back to why we need vir_init_n_int().
Also this would be possible.
>
> I agree that the fix to qemu_hotplug.c to not close fd 0 on failure is
> needed, but am not sure about the complexity of the virfile.h addition.
>
So a simple memset() would do? Having a macro for VIR_ALLOC_N_FD() would
probably be too much, eh?
Indeed:
$ git grep memset.*1
src/conf/domain_conf.c: memset(max_idx, -1, sizeof(max_idx));
src/qemu/qemu_command.c: memset(tapfd, -1, tapfdSize *
sizeof(tapfd[0]));
src/qemu/qemu_command.c: memset(vhostfd, -1, vhostfdSize *
sizeof(vhostfd[0]));
So let's just copy that convention, instead of adding a new macro.
ACK to the qemu_hotplug fixes if you switch to raw memset.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org