[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFi
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path |
Date: |
Mon, 23 Jul 2012 13:34:44 +0100 |
On 23 July 2012 12:33, Laszlo Ersek <address@hidden> wrote:
>
> Signed-off-by: Laszlo Ersek <address@hidden>
I think it would be much nicer to just rewrite qdev_get_fw_dev_path
so we weren't trying to fill the path into a fixed string buffer
at all. Here is an entirely untested implementation:
char *qdev_get_fw_dev_path(DeviceState *dev)
{
char *path;
char **strarray;
int depth = 0;
DeviceState *d = dev;
for (d = dev; d && d->parent_bus; d = d->parent_bus->parent) {
depth++;
}
depth++;
strarray = g_new(char*, depth);
for (d = dev; d && d->parent_bus; d = d->parent_bus->parent) {
depth--;
strarray[depth] = bus_get_fw_dev_path(dev->parent_bus, dev);
if (!strarray[depth]) {
strarray[depth] = g_strdup(object_get_typename(OBJECT(dev)));
}
}
strarray[0] = g_strdup("");
path = g_strjoinv("/", strarray);
g_strfreev(strarray);
return path;
}
Bonus extra patch: check that all the implementations of get_fw_dev_path()
are returning a g_malloc'd string rather than a plain malloc'd one
(both this code and the current implementation assume so but at least
the scsi bus implementation doesn't use the glib functions.)
-- PMM
- [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path, Laszlo Ersek, 2012/07/23
- Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path,
Peter Maydell <=
- Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path, Markus Armbruster, 2012/07/23
- Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path, Laszlo Ersek, 2012/07/23
- Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path, Markus Armbruster, 2012/07/23
- Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path, Laszlo Ersek, 2012/07/23
- Re: [Qemu-devel] [PATCH] check for available room when formatting OpenFirmware device path, Markus Armbruster, 2012/07/23
- [Qemu-devel] [PATCH v2 0/2] assorted device path formatting cleanups, Laszlo Ersek, 2012/07/24
- [Qemu-devel] [PATCH v2 1/2] accomodate OpenFirmware device paths in sufficient storage, Laszlo Ersek, 2012/07/24
- Re: [Qemu-devel] [PATCH v2 1/2] accomodate OpenFirmware device paths in sufficient storage, Peter Maydell, 2012/07/25
- Re: [Qemu-devel] [PATCH v2 1/2] accomodate OpenFirmware device paths in sufficient storage, Markus Armbruster, 2012/07/25