]> git.proxmox.com Git - qemu.git/commitdiff
error: Include the program name in error messages to stderr
authorMarkus Armbruster <armbru@redhat.com>
Wed, 24 Feb 2010 13:37:14 +0000 (14:37 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 16 Mar 2010 15:58:32 +0000 (16:58 +0100)
qemu-error.c
qemu-error.h
vl.c

index 0d673c517e34b6d5abcc842a93059dccf4db6952..214e4481e21bfa33d03c27979b5290c9e8b5976d 100644 (file)
@@ -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);
     }
 }
 
index a1562aaa0223a1c312fef6a72d461cb4761796e8..204dfb6a97e3c9818be2fcff968357586c8d600d 100644 (file)
@@ -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 error_report(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
 void qerror_report_internal(const char *file, int linenr, const char *func,
                             const char *fmt, ...)
diff --git a/vl.c b/vl.c
index 160f30a3205c237628224f0b2f33e2a3ce4ba667..c3abeeff2e8a14a423020697434de60ec2559fa8 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4862,6 +4862,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);