mirror of https://github.com/xqemu/xqemu.git
error: Don't abuse qemu_error() for non-error in qbus_find()
qbus_find() adds an informational line to error messages, and prints both lines with one qemu_error(). Use error_printf() for the informational line instead. While there, simplify: instead of printing buffers filled by qbus_list_bus() and qbus_list_dev() in one go, make them print it.
This commit is contained in:
parent
8a9662ca67
commit
53db16b5b0
37
hw/qdev.c
37
hw/qdev.c
|
@ -456,35 +456,33 @@ static DeviceState *qdev_find_recursive(BusState *bus, const char *id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qbus_list_bus(DeviceState *dev, char *dest, int len)
|
static void qbus_list_bus(DeviceState *dev)
|
||||||
{
|
{
|
||||||
BusState *child;
|
BusState *child;
|
||||||
const char *sep = " ";
|
const char *sep = " ";
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
pos += snprintf(dest+pos, len-pos,"child busses at \"%s\":",
|
error_printf("child busses at \"%s\":",
|
||||||
dev->id ? dev->id : dev->info->name);
|
dev->id ? dev->id : dev->info->name);
|
||||||
QLIST_FOREACH(child, &dev->child_bus, sibling) {
|
QLIST_FOREACH(child, &dev->child_bus, sibling) {
|
||||||
pos += snprintf(dest+pos, len-pos, "%s\"%s\"", sep, child->name);
|
error_printf("%s\"%s\"", sep, child->name);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
error_printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qbus_list_dev(BusState *bus, char *dest, int len)
|
static void qbus_list_dev(BusState *bus)
|
||||||
{
|
{
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
const char *sep = " ";
|
const char *sep = " ";
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
pos += snprintf(dest+pos, len-pos, "devices at \"%s\":",
|
error_printf("devices at \"%s\":", bus->name);
|
||||||
bus->name);
|
|
||||||
QLIST_FOREACH(dev, &bus->children, sibling) {
|
QLIST_FOREACH(dev, &bus->children, sibling) {
|
||||||
pos += snprintf(dest+pos, len-pos, "%s\"%s\"",
|
error_printf("%s\"%s\"", sep, dev->info->name);
|
||||||
sep, dev->info->name);
|
|
||||||
if (dev->id)
|
if (dev->id)
|
||||||
pos += snprintf(dest+pos, len-pos, "/\"%s\"", dev->id);
|
error_printf("/\"%s\"", dev->id);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
error_printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
|
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
|
||||||
|
@ -531,7 +529,7 @@ static BusState *qbus_find(const char *path)
|
||||||
{
|
{
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
BusState *bus;
|
BusState *bus;
|
||||||
char elem[128], msg[256];
|
char elem[128];
|
||||||
int pos, len;
|
int pos, len;
|
||||||
|
|
||||||
/* find start element */
|
/* find start element */
|
||||||
|
@ -565,8 +563,8 @@ static BusState *qbus_find(const char *path)
|
||||||
pos += len;
|
pos += len;
|
||||||
dev = qbus_find_dev(bus, elem);
|
dev = qbus_find_dev(bus, elem);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
qbus_list_dev(bus, msg, sizeof(msg));
|
qemu_error("device \"%s\" not found\n", elem);
|
||||||
qemu_error("device \"%s\" not found\n%s\n", elem, msg);
|
qbus_list_dev(bus);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (path[pos] == '\0') {
|
if (path[pos] == '\0') {
|
||||||
|
@ -579,9 +577,8 @@ static BusState *qbus_find(const char *path)
|
||||||
case 1:
|
case 1:
|
||||||
return QLIST_FIRST(&dev->child_bus);
|
return QLIST_FIRST(&dev->child_bus);
|
||||||
default:
|
default:
|
||||||
qbus_list_bus(dev, msg, sizeof(msg));
|
qemu_error("device has multiple child busses (%s)\n", path);
|
||||||
qemu_error("device has multiple child busses (%s)\n%s\n",
|
qbus_list_bus(dev);
|
||||||
path, msg);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,8 +591,8 @@ static BusState *qbus_find(const char *path)
|
||||||
pos += len;
|
pos += len;
|
||||||
bus = qbus_find_bus(dev, elem);
|
bus = qbus_find_bus(dev, elem);
|
||||||
if (!bus) {
|
if (!bus) {
|
||||||
qbus_list_bus(dev, msg, sizeof(msg));
|
qemu_error("child bus \"%s\" not found\n", elem);
|
||||||
qemu_error("child bus \"%s\" not found\n%s\n", elem, msg);
|
qbus_list_bus(dev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue