From patchwork Thu Mar 4 15:56:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 46933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 99EE2B7D2B for ; Fri, 5 Mar 2010 03:31:44 +1100 (EST) Received: from localhost ([127.0.0.1]:41383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnDxd-0004cF-Ao for incoming@patchwork.ozlabs.org; Thu, 04 Mar 2010 11:31:41 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NnDQp-0000gs-3J for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:47 -0500 Received: from [199.232.76.173] (port=35966 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnDQm-0000eL-I1 for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:44 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NnDQS-0000JM-Tp for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:43 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:39626) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NnDQQ-0000HI-Bk for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:23 -0500 Received: from blackfin.pond.sub.org (pD9E38041.dip.t-dialin.net [217.227.128.65]) by oxygen.pond.sub.org (Postfix) with ESMTPA id B5A01276DB3 for ; Thu, 4 Mar 2010 16:57:13 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 7464710A; Thu, 4 Mar 2010 16:57:12 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 4 Mar 2010 16:56:34 +0100 Message-Id: <1267718231-13303-14-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1267718231-13303-1-git-send-email-armbru@redhat.com> References: <1267718231-13303-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Luiz Capitulino Subject: [Qemu-devel] [PATCH 13/50] error: Don't abuse qemu_error() for non-error in qdev_device_help() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Markus Armbruster --- hw/qdev.c | 31 ++++++++++--------------------- 1 files changed, 10 insertions(+), 21 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index d0052d4..6842bd6 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -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); } }