From patchwork Mon Feb 11 16:41:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 14739 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CF84B23E33 for ; Mon, 11 Feb 2013 16:41:36 +0000 (UTC) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by fiordland.canonical.com (Postfix) with ESMTP id 439BAA18157 for ; Mon, 11 Feb 2013 16:41:36 +0000 (UTC) Received: by mail-ve0-f177.google.com with SMTP id m1so5296970ves.36 for ; Mon, 11 Feb 2013 08:41:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=K9GyaIrC8hUGBANaODsjwUi0nN8Czo0yhbxEz5iXtMo=; b=Dbevp211LG1zn6oXrYFL9/ZpxgS/v8SJEkTkLIxISGs6YT2GaH+AQIb5lu+XWNYQaR q9leK4IVP8jsNExeKdGNZIZLWFfD+65ERGUQEa/k9qLL5SLLVkzvknIuc+G0qTO4gYn2 l8FJwomKnBEcNmeAwnaAFOa3b7qUcHu2rKZfLKXLzo9ovVPXTdDl6/DPJ9M7UyARe0h8 xi0DRQ9sAJH81gBCHxR1/KYaVg91ejqOELLcU+vV1d9DcC3kKbsdinMJu8oWoJmauScP rZYPqxGb15CLD8uuj8PFmpBmtTh31s1IC08kpJZT9TloWGZYAyyRBv45d4hPbV4r2VP2 n+IA== X-Received: by 10.58.76.193 with SMTP id m1mr1825061vew.4.1360600895772; Mon, 11 Feb 2013 08:41:35 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp106484vec; Mon, 11 Feb 2013 08:41:35 -0800 (PST) X-Received: by 10.204.147.138 with SMTP id l10mr4294564bkv.84.1360600890658; Mon, 11 Feb 2013 08:41:30 -0800 (PST) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id w7si20154813bkv.215.2013.02.11.08.41.29 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 11 Feb 2013 08:41:30 -0800 (PST) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1U4wRZ-0001o4-VT; Mon, 11 Feb 2013 16:41:25 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Blue Swirl , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Stefan Hajnoczi Subject: [PATCH 2/6] qemu-log: Abstract out "print usage message about valid log categories" Date: Mon, 11 Feb 2013 16:41:21 +0000 Message-Id: <1360600885-6917-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1360600885-6917-1-git-send-email-peter.maydell@linaro.org> References: <1360600885-6917-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQnvEWgdY2XEGQrxdBUORyQkBQ3jeiJJpAyo9o2SV6VKPfKgTaURTyLw1rawZGZXcCkxmAH8 Abstract out the "print a human readable list of all the valid log categories" functionality which is currently duplicated in three separate places. (We leave the monitor.c help_cmd() implementation as-is since it wants to send the message to the monitor and add its own information.) Signed-off-by: Peter Maydell Reviewed-by: Andreas Färber --- bsd-user/main.c | 6 +----- cpus.c | 6 +----- include/qemu/log.h | 5 +++++ linux-user/main.c | 6 +----- qemu-log.c | 9 +++++++++ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 76ab359..26604b4 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -864,14 +864,10 @@ int main(int argc, char **argv) qemu_set_log_filename(log_file); if (log_mask) { int mask; - const CPULogItem *item; mask = cpu_str_to_log_mask(log_mask); if (!mask) { - printf("Log items (comma separated):\n"); - for (item = cpu_log_items; item->mask != 0; item++) { - printf("%-10s %s\n", item->name, item->help); - } + qemu_print_log_usage(stdout); exit(1); } cpu_set_log(mask); diff --git a/cpus.c b/cpus.c index 2155441..0fdc48c 100644 --- a/cpus.c +++ b/cpus.c @@ -1178,14 +1178,10 @@ void set_numa_modes(void) void set_cpu_log(const char *optarg) { int mask; - const CPULogItem *item; mask = cpu_str_to_log_mask(optarg); if (!mask) { - printf("Log items (comma separated):\n"); - for (item = cpu_log_items; item->mask != 0; item++) { - printf("%-10s %s\n", item->name, item->help); - } + qemu_print_log_usage(stdout); exit(1); } cpu_set_log(mask); diff --git a/include/qemu/log.h b/include/qemu/log.h index 4760e04..59511a3 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -157,4 +157,9 @@ static inline void cpu_set_log(int log_flags) void qemu_set_log_filename(const char *filename); int cpu_str_to_log_mask(const char *str); +/* Print a usage message listing all the valid logging categories + * to the specified FILE*. + */ +void qemu_print_log_usage(FILE *f); + #endif diff --git a/linux-user/main.c b/linux-user/main.c index 99219ef..81eb126 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3098,14 +3098,10 @@ static void handle_arg_help(const char *arg) static void handle_arg_log(const char *arg) { int mask; - const CPULogItem *item; mask = cpu_str_to_log_mask(arg); if (!mask) { - printf("Log items (comma separated):\n"); - for (item = cpu_log_items; item->mask != 0; item++) { - printf("%-10s %s\n", item->name, item->help); - } + qemu_print_log_usage(stdout); exit(1); } cpu_set_log(mask); diff --git a/qemu-log.c b/qemu-log.c index 9a7e567..786d335 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -170,3 +170,12 @@ int cpu_str_to_log_mask(const char *str) } return mask; } + +void qemu_print_log_usage(FILE *f) +{ + const CPULogItem *item; + fprintf(f, "Log items (comma separated):\n"); + for (item = cpu_log_items; item->mask != 0; item++) { + fprintf(f, "%-10s %s\n", item->name, item->help); + } +}