Re: [RFC v4 04/13] hw/vfio/pci: introduce VFIODevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23 July 2014 11:02, Eric Auger <eric.auger@xxxxxxxxxx> wrote:
> On 07/09/2014 12:41 AM, Alex Williamson wrote:
>> On Mon, 2014-07-07 at 13:27 +0100, Eric Auger wrote:
>>> +    vdev->vbasedev.ops = &vfio_pci_ops;
>>> +
>>> +    vdev->vbasedev.type = VFIO_DEVICE_TYPE_PCI;
>>> +    vdev->vbasedev.name = g_malloc0(PATH_MAX);
>>> +    snprintf(vdev->vbasedev.name, PATH_MAX, "%04x:%02x:%02x.%01x",
>>> +            vdev->host.domain, vdev->host.bus, vdev->host.slot,
>>> +            vdev->host.function);
>>> +
>>
>> asprintf(3)?  This is a deterministic length, so PATH_MAX is especially
>> ridiculous.
> agreed, will use asprintf instead.

A minor nit given this is going to be in "only on Linux"
code, but we generally prefer g_strdup_printf() over
raw asprintf() (they do the same thing, but the glib
function is guaranteed to be present everywhere,
and the returned memory is freeable with g_free()
like most of our strings, rather than needing to remember
that it needs to be freed via free().)

thanks
-- PMM
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm




[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux