mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
error: Include the program name in error messages to stderr
This commit is contained in:
parent
827b08139c
commit
65abca0a34
3 changed files with 22 additions and 1 deletions
20
qemu-error.c
20
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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, ...)
|
||||
|
|
2
vl.c
2
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);
|
||||
|
|
Loading…
Reference in a new issue