From patchwork Wed Feb 24 17:55:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 46164 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 9DCC3B7067 for ; Thu, 25 Feb 2010 05:32:19 +1100 (EST) Received: from localhost ([127.0.0.1]:55927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkM1w-0007gc-Qo for incoming@patchwork.ozlabs.org; Wed, 24 Feb 2010 13:32:16 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NkLbB-0001ia-Rt for qemu-devel@nongnu.org; Wed, 24 Feb 2010 13:04:37 -0500 Received: from [199.232.76.173] (port=52937 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkLbB-0001iC-33 for qemu-devel@nongnu.org; Wed, 24 Feb 2010 13:04:37 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NkLb7-000053-9l for qemu-devel@nongnu.org; Wed, 24 Feb 2010 13:04:36 -0500 Received: from mx20.gnu.org ([199.232.41.8]:5290) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NkLb6-0008VJ-L0 for qemu-devel@nongnu.org; Wed, 24 Feb 2010 13:04:32 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NkLb4-000161-VL for qemu-devel@nongnu.org; Wed, 24 Feb 2010 13:04:31 -0500 Received: from blackfin.pond.sub.org (pD9E38C12.dip.t-dialin.net [217.227.140.18]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 1EEF2276D9F for ; Wed, 24 Feb 2010 19:04:30 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id B080DF8; Wed, 24 Feb 2010 18:56:01 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 24 Feb 2010 18:55:30 +0100 Message-Id: <1267034160-3517-19-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1267034160-3517-1-git-send-email-armbru@redhat.com> References: <1267034160-3517-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH RFC 18/48] error: Include the program name in error messages to stderr 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 Signed-off-by: Markus Armbruster --- qemu-error.c | 20 +++++++++++++++++++- qemu-error.h | 1 + vl.c | 2 ++ 3 files changed, 22 insertions(+), 1 deletions(-) diff --git a/qemu-error.c b/qemu-error.c index 0778001..b2c0a80 100644 --- a/qemu-error.c +++ b/qemu-error.c @@ -113,13 +113,31 @@ void loc_set_none(void) cur_loc->kind = LOC_NONE; } +static const char *progname; + +/* + * Set the program name for error_print_loc(). + */ +void error_set_progname(const char *argv0) +{ + const char *p = strrchr(argv0, '/'); + progname = p ? p + 1 : argv0; +} + /* * Print current location to current monitor if we have one, else to stderr. */ void error_print_loc(void) { + const char *sep = ""; + + if (!cur_mon) { + fprintf(stderr, "%s:", progname); + sep = " "; + } switch (cur_loc->kind) { - default: ; + default: + error_printf(sep); } } diff --git a/qemu-error.h b/qemu-error.h index ebf4bf9..22f3c79 100644 --- a/qemu-error.h +++ b/qemu-error.h @@ -31,6 +31,7 @@ void loc_set_none(void); void error_vprintf(const char *fmt, va_list ap); void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void error_print_loc(void); +void error_set_progname(const char *argv0); void qemu_error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void qemu_error_internal(const char *file, int linenr, const char *func, const char *fmt, ...) diff --git a/vl.c b/vl.c index 7d4b234..ac1db72 100644 --- a/vl.c +++ b/vl.c @@ -4822,6 +4822,8 @@ int main(int argc, char **argv, char **envp) int show_vnc_port = 0; int defconfig = 1; + error_set_progname(argv[0]); + init_clocks(); qemu_cache_utils_init(envp);