From patchwork Mon Jul 27 15:06:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 500467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 299AE1401EF for ; Tue, 28 Jul 2015 01:07:09 +1000 (AEST) Received: from localhost ([::1]:54050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJjzf-000247-2M for incoming@patchwork.ozlabs.org; Mon, 27 Jul 2015 11:07:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJjzN-0001lt-Sh for qemu-devel@nongnu.org; Mon, 27 Jul 2015 11:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJjzJ-0003SX-64 for qemu-devel@nongnu.org; Mon, 27 Jul 2015 11:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJjzJ-0003ST-0u for qemu-devel@nongnu.org; Mon, 27 Jul 2015 11:06:45 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 13B92ADADF; Mon, 27 Jul 2015 15:06:44 +0000 (UTC) Received: from [10.36.112.44] (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6RF6ep0012301 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Jul 2015 11:06:42 -0400 To: =?UTF-8?Q?Andreas_F=c3=a4rber?= , Pavel Fedin , "'Markus Armbruster'" References: <507c11db2c97eef33de0e4f7168076d5c39f0867.1436866326.git.p.fedin@samsung.com> <87r3ntzra9.fsf@blackfin.pond.sub.org> <003201d0c879$8fced800$af6c8800$@samsung.com> <55B646CD.8010808@suse.de> From: Paolo Bonzini Message-ID: <55B64900.6020008@redhat.com> Date: Mon, 27 Jul 2015 17:06:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <55B646CD.8010808@suse.de> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: 'Peter Crosthwaite' , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH v4 2/2] QOM: object_property_add() performance improvement X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 27/07/2015 16:57, Andreas Färber wrote: >> > I am absolutely fine with absolutely anything. Suggest what you like and i'll change it. > Paolo suggested ...-count on #qemu, but I would prefer ...-max or so, as > the number could differ when some property gets deleted. Yes, I agree -max is better. I'm just asking myself whether this is really necessary. Is the automagic [*] really needed in this case? Can it just do: ? Paolo > On the other hand, since this is not a user-added property, using a > reserved character such as '#' would avoid clashes with user-added > properties, as long as tools handle accessing that property okay. diff --git a/hw/core/qdev.c b/hw/core/qdev.c index b2f404a..19bfee1 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -415,19 +415,19 @@ static NamedGPIOList *qdev_get_named_gpio_list(DeviceState *dev, void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler, const char *name, int n) { - int i; + int i, j; NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name); - char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-in"); assert(gpio_list->num_out == 0 || !name); gpio_list->in = qemu_extend_irqs(gpio_list->in, gpio_list->num_in, handler, dev, n); for (i = gpio_list->num_in; i < gpio_list->num_in + n; i++) { + char *propname = g_strdup_printf("%s[%d]", name ? name : "unnamed-gpio-in", j++); object_property_add_child(OBJECT(dev), propname, OBJECT(gpio_list->in[i]), &error_abort); + g_free(propname); } - g_free(propname); gpio_list->num_in += n; }