From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9MrS-0005zp-2L for qemu-devel@nongnu.org; Wed, 16 Dec 2015 19:56:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9MrR-00020U-1M for qemu-devel@nongnu.org; Wed, 16 Dec 2015 19:56:02 -0500 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:36687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9MrQ-00020P-Sk for qemu-devel@nongnu.org; Wed, 16 Dec 2015 19:56:00 -0500 Received: by mail-oi0-x235.google.com with SMTP id o62so29784461oif.3 for ; Wed, 16 Dec 2015 16:56:00 -0800 (PST) MIME-Version: 1.0 Sender: alistair23@gmail.com In-Reply-To: References: From: Alistair Francis Date: Wed, 16 Dec 2015 16:55:30 -0800 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v5 4/6] qdev: Add a function to rename busses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: Peter Maydell , "qemu-devel@nongnu.org Developers" , Alistair Francis On Wed, Dec 16, 2015 at 2:36 PM, Peter Crosthwaite wrote: > On Wed, Dec 16, 2015 at 1:45 PM, Alistair Francis > wrote: >> Add a function which can be used to rename busses. >> >> Signed-off-by: Alistair Francis >> --- >> >> hw/core/qdev.c | 5 +++++ >> include/hw/qdev-core.h | 2 ++ >> 2 files changed, 7 insertions(+) >> >> diff --git a/hw/core/qdev.c b/hw/core/qdev.c >> index b3ad467..29a3e9d 100644 >> --- a/hw/core/qdev.c >> +++ b/hw/core/qdev.c >> @@ -590,6 +590,11 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name) >> return NULL; >> } >> >> +void qdev_bus_rename(BusState *bus, const char *name) >> +{ >> + memcpy((char *) bus->name, name, strlen(name) * sizeof(char)); > > sizeof(char) not needed, but wont this assume the current name is long > enough to hold the new name? Should name just be strduped and the old > name freed? You are right, that is better. I will update it to use strdup() and I will also move the function inside xlnx-zynqmp.c as requested by Paolo. I'll give it a day to see if there are any other comments before sending it out again. Thanks, Alistair > > Regards, > Peter > >> +} >> + >> int qbus_walk_children(BusState *bus, >> qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn, >> qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn, >> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h >> index c537969..9653f4d 100644 >> --- a/include/hw/qdev-core.h >> +++ b/include/hw/qdev-core.h >> @@ -297,6 +297,8 @@ qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt, >> >> BusState *qdev_get_child_bus(DeviceState *dev, const char *name); >> >> +void qdev_bus_rename(BusState *bus, const char *name); >> + >> /*** Device API. ***/ >> >> /* Register device properties. */ >> -- >> 2.5.0 >> >