From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfCRu-0001FB-Uv for qemu-devel@nongnu.org; Thu, 14 Jun 2012 11:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfCRs-0005J8-B7 for qemu-devel@nongnu.org; Thu, 14 Jun 2012 11:59:06 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:22351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfCRs-0005Ib-6g for qemu-devel@nongnu.org; Thu, 14 Jun 2012 11:59:04 -0400 Message-ID: <4FDA0A45.8030503@citrix.com> Date: Thu, 14 Jun 2012 16:59:01 +0100 From: Anthony PERARD MIME-Version: 1.0 References: <1339513523-1699-1-git-send-email-anthony.perard@citrix.com> <1339513523-1699-6-git-send-email-anthony.perard@citrix.com> <20120612151557.GA10691@redhat.com> <4FD8764B.9060003@siemens.com> <4FD880D3.8090203@siemens.com> <4FD88A33.1080304@citrix.com> <4FD88C0D.10304@siemens.com> <4FD9F789.5070300@citrix.com> <20120614153014.GB18618@redhat.com> In-Reply-To: <20120614153014.GB18618@redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Jan Kiszka , Anthony Liguori , Xen Devel , QEMU-devel , Stefano Stabellini 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