diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2012-07-20 13:43:37 -0300 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-08-13 13:20:01 -0300 |
commit | dd7520f0646985b08024c73ba2285c31d7318755 (patch) | |
tree | 89618447aa2859da1b7e32c1b25d2dc323c5e36a /error.c | |
parent | 18da7c0f1f24cc00f7c2f80c27cb85e4b234e091 (diff) | |
download | qemu-dd7520f0646985b08024c73ba2285c31d7318755.zip qemu-dd7520f0646985b08024c73ba2285c31d7318755.tar.gz qemu-dd7520f0646985b08024c73ba2285c31d7318755.tar.bz2 |
error: don't delay error message construction
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 <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 8 |
1 files changed, 1 insertions, 7 deletions
@@ -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; } |