[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/14] qerror: qerror_format(): return an allocated
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 05/14] qerror: qerror_format(): return an allocated string |
Date: |
Wed, 25 Jul 2012 17:50:22 -0300 |
Simplifies current and future users.
Signed-off-by: Luiz Capitulino <address@hidden>
---
error.c | 5 +----
qerror.c | 10 ++++++++--
qerror.h | 2 +-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/error.c b/error.c
index a52b771..b630b05 100644
--- a/error.c
+++ b/error.c
@@ -64,10 +64,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 8138186..7db28fc 100644
--- a/qerror.c
+++ b/qerror.c
@@ -207,9 +207,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++) {
@@ -219,7 +221,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 929017c..6bf941b 100644
--- a/qerror.h
+++ b/qerror.h
@@ -35,6 +35,6 @@ 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);
#endif /* QERROR_H */
--
1.7.11.2.249.g31c7954.dirty
- [Qemu-devel] [RFC 00/14]: add printf-like human msg to error_set(), Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 01/14] monitor: drop unused monitor debug code, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 02/14] qerror: reduce public exposure, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 03/14] qerror: drop qerror_abort(), Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 04/14] qerror: drop qerror_report_internal(), Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 05/14] qerror: qerror_format(): return an allocated string,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 06/14] qerror: don't delay error message construction, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 07/14] error: don't delay error message construction, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 08/14] qerror: add build_error_dict() and error_object_table[], Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 09/14] qerror: qerror_report(): take an index and a human error message, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 11/14] qerror: drop qerror_table[] for good, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 12/14] error: turn QERR_ macros into an enumeration, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 13/14] qerror: change all qerror_report() calls to use the ErrClass enum, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 10/14] error: error_set(): take an index and a human error message, Luiz Capitulino, 2012/07/25