mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
util/error: make func optional
The function name is not available in Rust, so make it optional. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
230a4894f4
commit
e8fb9c91a3
2 changed files with 9 additions and 2 deletions
|
@ -18,6 +18,8 @@ struct Error
|
||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
ErrorClass err_class;
|
ErrorClass err_class;
|
||||||
|
|
||||||
|
/* Used for error_abort only, may be NULL. */
|
||||||
const char *func;
|
const char *func;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,8 +24,13 @@ Error *error_warn;
|
||||||
static void error_handle(Error **errp, Error *err)
|
static void error_handle(Error **errp, Error *err)
|
||||||
{
|
{
|
||||||
if (errp == &error_abort) {
|
if (errp == &error_abort) {
|
||||||
fprintf(stderr, "Unexpected error in %s() at %.*s:%d:\n",
|
if (err->func) {
|
||||||
err->func, err->src_len, err->src, err->line);
|
fprintf(stderr, "Unexpected error in %s() at %.*s:%d:\n",
|
||||||
|
err->func, err->src_len, err->src, err->line);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Unexpected error at %.*s:%d:\n",
|
||||||
|
err->src_len, err->src, err->line);
|
||||||
|
}
|
||||||
error_report("%s", error_get_pretty(err));
|
error_report("%s", error_get_pretty(err));
|
||||||
if (err->hint) {
|
if (err->hint) {
|
||||||
error_printf("%s", err->hint->str);
|
error_printf("%s", err->hint->str);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue