aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2012-07-20 13:30:18 -0300
committerLuiz Capitulino <lcapitulino@redhat.com>2012-08-13 13:19:52 -0300
commit2b38cf2e033d90fb50fc967f535935b170dc507d (patch)
tree1ac9ec5b947b22ceba04eea19d134458a1c40732
parent5f0f0e13e1f714704d96f04050674c3102376409 (diff)
downloadqemu-2b38cf2e033d90fb50fc967f535935b170dc507d.zip
qemu-2b38cf2e033d90fb50fc967f535935b170dc507d.tar.gz
qemu-2b38cf2e033d90fb50fc967f535935b170dc507d.tar.bz2
qerror: qerror_format(): return an allocated string
Simplifies current and future users. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r--error.c5
-rw-r--r--qerror.c10
-rw-r--r--qerror.h2
3 files changed, 10 insertions, 7 deletions
diff --git a/error.c b/error.c
index 58f55a0..3a62592 100644
--- a/error.c
+++ b/error.c
@@ -65,10 +65,7 @@ bool error_is_set(Error **errp)
const char *error_get_pretty(Error *err)
{
if (err->msg == NULL) {
- QString *str;
- str = qerror_format(err->fmt, err->obj);
- err->msg = g_strdup(qstring_get_str(str));
- QDECREF(str);
+ err->msg = qerror_format(err->fmt, err->obj);
}
return err->msg;
diff --git a/qerror.c b/qerror.c
index 6f9f49c..d073ed7 100644
--- a/qerror.c
+++ b/qerror.c
@@ -493,9 +493,11 @@ static QString *qerror_format_desc(QDict *error,
return qstring;
}
-QString *qerror_format(const char *fmt, QDict *error)
+char *qerror_format(const char *fmt, QDict *error)
{
const QErrorStringTable *entry = NULL;
+ QString *qstr;
+ char *ret;
int i;
for (i = 0; qerror_table[i].error_fmt; i++) {
@@ -505,7 +507,11 @@ QString *qerror_format(const char *fmt, QDict *error)
}
}
- return qerror_format_desc(error, entry);
+ qstr = qerror_format_desc(error, entry);
+ ret = g_strdup(qstring_get_str(qstr));
+ QDECREF(qstr);
+
+ return ret;
}
/**
diff --git a/qerror.h b/qerror.h
index 3c0b14c..aec76b2 100644
--- a/qerror.h
+++ b/qerror.h
@@ -34,7 +34,7 @@ QString *qerror_human(const QError *qerror);
void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void qerror_report_err(Error *err);
void assert_no_error(Error *err);
-QString *qerror_format(const char *fmt, QDict *error);
+char *qerror_format(const char *fmt, QDict *error);
/*
* QError class list