[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/48] error: don't delay error message construction
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 10/48] error: don't delay error message construction |
Date: |
Mon, 13 Aug 2012 16:48:31 -0300 |
Today, the error message is only constructed when it's used. This commit
changes that to construct the error message when the error object is
built (ie. when the error is reported).
This simplifies the Error object.
Signed-off-by: Luiz Capitulino <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
---
error.c | 8 +-------
qerror.c | 4 +---
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/error.c b/error.c
index 3a62592..2ade99b 100644
--- a/error.c
+++ b/error.c
@@ -20,7 +20,6 @@
struct Error
{
QDict *obj;
- const char *fmt;
char *msg;
};
@@ -39,7 +38,7 @@ void error_set(Error **errp, const char *fmt, ...)
va_start(ap, fmt);
err->obj = qobject_to_qdict(qobject_from_jsonv(fmt, &ap));
va_end(ap);
- err->fmt = fmt;
+ err->msg = qerror_format(fmt, err->obj);
*errp = err;
}
@@ -50,7 +49,6 @@ Error *error_copy(const Error *err)
err_new = g_malloc0(sizeof(*err));
err_new->msg = g_strdup(err->msg);
- err_new->fmt = err->fmt;
err_new->obj = err->obj;
QINCREF(err_new->obj);
@@ -64,10 +62,6 @@ bool error_is_set(Error **errp)
const char *error_get_pretty(Error *err)
{
- if (err->msg == NULL) {
- err->msg = qerror_format(err->fmt, err->obj);
- }
-
return err->msg;
}
diff --git a/qerror.c b/qerror.c
index a254f88..5d38428 100644
--- a/qerror.c
+++ b/qerror.c
@@ -543,7 +543,6 @@ void qerror_report(const char *fmt, ...)
struct Error
{
QDict *obj;
- const char *fmt;
char *msg;
};
@@ -555,8 +554,7 @@ void qerror_report_err(Error *err)
loc_save(&qerr->loc);
QINCREF(err->obj);
qerr->error = err->obj;
-
- qerr->err_msg = qerror_format(err->fmt, qerr->error);
+ qerr->err_msg = g_strdup(err->msg);
if (monitor_cur_is_qmp()) {
monitor_set_error(cur_mon, qerr);
--
1.7.11.2.249.g31c7954.dirty
- [Qemu-devel] [PULL 00/48]: QMP queue, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 01/48] monitor: drop unused monitor debug code, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 02/48] qerror: QERR_AMBIGUOUS_PATH: drop %(object) from human msg, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 03/48] qerror: QERR_DEVICE_ENCRYPTED: change error message, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 04/48] qerror: reduce public exposure, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 05/48] qerror: drop qerror_abort(), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 06/48] qerror: avoid passing qerr pointer, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 08/48] qerror: qerror_format(): return an allocated string, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 07/48] qerror: QError: drop file, linenr, func, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 10/48] error: don't delay error message construction,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 11/48] qmp: query-block: add 'encryption_key_missing' field, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 09/48] qerror: don't delay error message construction, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 12/48] hmp: hmp_cont(): don't rely on QERR_DEVICE_ENCRYPTED, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 14/48] net: inet_connect(), inet_connect_opts(): add in_progress argument, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 13/48] hmp_change(): don't access DeviceEncrypted's data, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 16/48] qerror: drop QERR_SOCKET_CONNECT_IN_PROGRESS, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 15/48] migration: don't rely on any QERR_SOCKET_*, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 17/48] block: block_int: include qerror.h, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 20/48] qapi: generate correct enum names for camel case enums, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 19/48] qapi: qapi-types.h: don't include qapi/qapi-types-core.h, Luiz Capitulino, 2012/08/13