qemu-devel
[Top][All Lists]
Advanced

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

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


From: Peter Maydell
Subject: Re: [Qemu-devel] [RFC v4 04/13] hw/vfio/pci: introduce VFIODevice
Date: Wed, 23 Jul 2014 11:24:49 +0100

On 23 July 2014 11:02, Eric Auger <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]