On 09/11/2014 11:16 AM, Peter Krempa wrote: >> struct _virDomainInterfaceStats { >> long long rx_bytes; >> long long rx_packets; >> long long rx_errs; >> long long rx_drop; >> long long tx_bytes; >> long long tx_packets; >> long long tx_errs; >> long long tx_drop; >> }; >> >> But I don't have any problem to cast them as unsigned, with something like: > > That will be fine with me as long as: >> >> #define QEMU_ADD_NET_PARAM(record, maxparams, num, name, value) \ >> do { \ >> char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \ >> snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \ >> "net.%u.%s", num, name); \ >> if (virTypedParamsAddULLong(&(record)->params, \ > > ... you don't add the param if value is < 0. Thus rather than expressing > the missing information via -1 just omit the parameter. > >> &(record)->nparams, \ >> maxparams, \ >> param_name, \ >> (unsigned long long)value) < 0) \ The cast is spurious; the C compiler does the right thing if you already filter on value < 0 before calling this function to add the positive values as unsigned long long. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list