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

Re: [Xen-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"



On 14/06/12 16:30, Michael S. Tsirkin wrote:
>  Is this patch would be a good common property?
>
>  It's probably close to the patch you send earlier Jan.
>
>  If it's good, I'll resend my passthrough patch series with this patch.
>
>
>  diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
>  index b7b5597..9c7a271 100644
>  --- a/hw/qdev-properties.c
>  +++ b/hw/qdev-properties.c
>  @@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
>        .max   = 65024,
>    };
>
>  +/* --- pci host address --- */
>  +
>  +static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
>  +                                 const char *name, Error **errp)
>  +{
>  +    DeviceState *dev = DEVICE(obj);
>  +    Property *prop = opaque;
>  +    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
>  +    char buffer[4 + 2 + 2 + 2 + 1];
One trick is this:
     char buffer[] = "XXXX:XX:XX.X";

I love this trick, even if it use a bit of space in the binary, I think. I will use it.

And comparing with the above, your buffer looks too short, doesn't it?

Yes, I think I forgot to count the ':'s and '.'.

>  +    char *p = buffer;
>  +
>  +    snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
>  +             addr->domain, addr->bus, addr->slot, addr->function);
A good idea might be to check the return code. assert(ret<= sizeof buf).

I will.

Thanks,

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.