diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-02-18 18:44:15 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2010-03-16 16:55:05 +0100 |
commit | 8a9662ca67c7ecb6cc3d9b2055438bacbf61682e (patch) | |
tree | 45b9872d9d11e6aaae4d1828d936e5f37a5e2451 /hw/qdev.c | |
parent | ba0fe87acd8937d403f60da63290aadb0b84827e (diff) | |
download | qemu-8a9662ca67c7ecb6cc3d9b2055438bacbf61682e.tar.gz qemu-8a9662ca67c7ecb6cc3d9b2055438bacbf61682e.tar.bz2 qemu-8a9662ca67c7ecb6cc3d9b2055438bacbf61682e.zip |
error: Don't abuse qemu_error() for non-error in qdev_device_help()
qdev_device_help() prints device information with qemu_error(). A
later commit will make qemu_error() print additional stuff that is
only appropriate for proper errors, and then this will break. Use
error_printf() instead.
While there, simplify: instead of printing a buffer filled by
qdev_print_devinfo() in one go, make qdev_print_devinfo() print it.
Diffstat (limited to 'hw/qdev.c')
-rw-r--r-- | hw/qdev.c | 31 |
1 files changed, 10 insertions, 21 deletions
@@ -113,27 +113,20 @@ DeviceState *qdev_create(BusState *bus, const char *name) return dev; } -static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len) +static void qdev_print_devinfo(DeviceInfo *info) { - int pos = 0; - int ret; - - ret = snprintf(dest+pos, len-pos, "name \"%s\", bus %s", - info->name, info->bus_info->name); - pos += MIN(len-pos,ret); + error_printf("name \"%s\", bus %s", + info->name, info->bus_info->name); if (info->alias) { - ret = snprintf(dest+pos, len-pos, ", alias \"%s\"", info->alias); - pos += MIN(len-pos,ret); + error_printf(", alias \"%s\"", info->alias); } if (info->desc) { - ret = snprintf(dest+pos, len-pos, ", desc \"%s\"", info->desc); - pos += MIN(len-pos,ret); + error_printf(", desc \"%s\"", info->desc); } if (info->no_user) { - ret = snprintf(dest+pos, len-pos, ", no-user"); - pos += MIN(len-pos,ret); + error_printf(", no-user"); } - return pos; + error_printf("\n"); } static int set_property(const char *name, const char *value, void *opaque) @@ -157,14 +150,12 @@ int qdev_device_help(QemuOpts *opts) { const char *driver; DeviceInfo *info; - char msg[256]; Property *prop; driver = qemu_opt_get(opts, "driver"); if (driver && !strcmp(driver, "?")) { for (info = device_info_list; info != NULL; info = info->next) { - qdev_print_devinfo(info, msg, sizeof(msg)); - qemu_error("%s\n", msg); + qdev_print_devinfo(info); } return 1; } @@ -179,7 +170,7 @@ int qdev_device_help(QemuOpts *opts) } for (prop = info->props; prop && prop->name; prop++) { - qemu_error("%s.%s=%s\n", info->name, prop->name, prop->info->name); + error_printf("%s.%s=%s\n", info->name, prop->name, prop->info->name); } return 1; } @@ -735,11 +726,9 @@ void do_info_qtree(Monitor *mon) void do_info_qdm(Monitor *mon) { DeviceInfo *info; - char msg[256]; for (info = device_info_list; info != NULL; info = info->next) { - qdev_print_devinfo(info, msg, sizeof(msg)); - monitor_printf(mon, "%s\n", msg); + qdev_print_devinfo(info); } } |