On Wed, Dec 16, 2015 at 1:45 PM, Alistair Francis <alistair.fran...@xilinx.com> wrote: > Add a function which can be used to rename busses. > > Signed-off-by: Alistair Francis <alistair.fran...@xilinx.com> > --- > > 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? 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 >