mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-04-30 12:36:20 +00:00
error: New error_fatal
Similar to error_abort, but doesn't report where the error was created, and terminates the process with exit(1) rather than abort(). Backports commit a29a37b994ca3c5a1d39fa0e8934f7e0f2cf57ef from qemu
This commit is contained in:
parent
c4a06e2d12
commit
91b4e76fef
|
@ -64,6 +64,9 @@
|
|||
* Call a function aborting on errors:
|
||||
* foo(arg, &error_abort);
|
||||
*
|
||||
* Call a function treating errors as fatal:
|
||||
* foo(arg, &error_fatal);
|
||||
*
|
||||
* Receive an error and pass it on to the caller:
|
||||
* Error *err = NULL;
|
||||
* foo(arg, &err);
|
||||
|
@ -241,4 +244,10 @@ void error_set_internal(Error **errp,
|
|||
*/
|
||||
extern Error *error_abort;
|
||||
|
||||
/*
|
||||
* Special error destination to exit(1) on error.
|
||||
* See error_setg() and error_propagate() for details.
|
||||
*/
|
||||
extern Error *error_fatal;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
* QEMU Error Objects
|
||||
*
|
||||
* Copyright IBM, Corp. 2011
|
||||
* Copyright (C) 2011-2015 Red Hat, Inc.
|
||||
*
|
||||
* Authors:
|
||||
* Anthony Liguori <aliguori@us.ibm.com>
|
||||
* Markus Armbruster <armbru@redhat.com>,
|
||||
*
|
||||
* This work is licensed under the terms of the GNU LGPL, version 2. See
|
||||
* the COPYING.LIB file in the top-level directory.
|
||||
|
@ -23,14 +25,23 @@ struct Error
|
|||
};
|
||||
|
||||
Error *error_abort;
|
||||
Error *error_fatal;
|
||||
|
||||
static void error_do_abort(Error *err)
|
||||
static void error_handle_fatal(Error **errp, Error *err)
|
||||
{
|
||||
fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
|
||||
err->func, err->src, err->line);
|
||||
// UNICORN: Commented out
|
||||
// error_report_err(err);
|
||||
// abort();
|
||||
if (errp == &error_abort) {
|
||||
fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
|
||||
err->func, err->src, err->line);
|
||||
|
||||
// Unicorn: commented out
|
||||
//error_report_err(err);
|
||||
//abort();
|
||||
}
|
||||
if (errp == &error_fatal) {
|
||||
// Unicorn: commented out
|
||||
//error_report_err(err);
|
||||
//exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void error_setv(Error **errp,
|
||||
|
@ -53,10 +64,7 @@ static void error_setv(Error **errp,
|
|||
err->line = line;
|
||||
err->func = func;
|
||||
|
||||
if (errp == &error_abort) {
|
||||
error_do_abort(err);
|
||||
}
|
||||
|
||||
error_handle_fatal(errp, err);
|
||||
*errp = err;
|
||||
|
||||
errno = saved_errno;
|
||||
|
@ -151,11 +159,13 @@ void error_free(Error *err)
|
|||
|
||||
void error_propagate(Error **dst_errp, Error *local_err)
|
||||
{
|
||||
if (local_err && dst_errp == &error_abort) {
|
||||
error_do_abort(local_err);
|
||||
} else if (dst_errp && !*dst_errp) {
|
||||
if (!local_err) {
|
||||
return;
|
||||
}
|
||||
error_handle_fatal(dst_errp, local_err);
|
||||
if (dst_errp && !*dst_errp) {
|
||||
*dst_errp = local_err;
|
||||
} else if (local_err) {
|
||||
} else {
|
||||
error_free(local_err);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue