[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/14] qerror: drop qerror_table[] for good
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 11/14] qerror: drop qerror_table[] for good |
Date: |
Wed, 25 Jul 2012 17:50:28 -0300 |
Last commit deprecated it. Also drops the code that used it to generate
error objects.
Signed-off-by: Luiz Capitulino <address@hidden>
---
qerror.c | 95 --------------------------------------------------
qerror.h | 6 ----
scripts/qapi-errors.py | 26 --------------
3 files changed, 127 deletions(-)
diff --git a/qerror.c b/qerror.c
index 6d61426..1118e2b 100644
--- a/qerror.c
+++ b/qerror.c
@@ -144,101 +144,6 @@ static QError *qerror_from_info(int err_class, const char
*fmt, va_list *va)
return qerr;
}
-static void parse_error(const QErrorStringTable *entry, int c)
-{
- fprintf(stderr, "expected '%c' in '%s'", c, entry->desc);
- abort();
-}
-
-static const char *append_field(QDict *error, QString *outstr,
- const QErrorStringTable *entry,
- const char *start)
-{
- QObject *obj;
- QDict *qdict;
- QString *key_qs;
- const char *end, *key;
-
- if (*start != '%')
- parse_error(entry, '%');
- start++;
- if (*start != '(')
- parse_error(entry, '(');
- start++;
-
- end = strchr(start, ')');
- if (!end)
- parse_error(entry, ')');
-
- key_qs = qstring_from_substr(start, 0, end - start - 1);
- key = qstring_get_str(key_qs);
-
- qdict = qobject_to_qdict(qdict_get(error, "data"));
- obj = qdict_get(qdict, key);
- if (!obj) {
- abort();
- }
-
- switch (qobject_type(obj)) {
- case QTYPE_QSTRING:
- qstring_append(outstr, qdict_get_str(qdict, key));
- break;
- case QTYPE_QINT:
- qstring_append_int(outstr, qdict_get_int(qdict, key));
- break;
- default:
- abort();
- }
-
- QDECREF(key_qs);
- return ++end;
-}
-
-static QString *qerror_format_desc(QDict *error,
- const QErrorStringTable *entry)
-{
- QString *qstring;
- const char *p;
-
- assert(entry != NULL);
-
- qstring = qstring_new();
-
- for (p = entry->desc; *p != '\0';) {
- if (*p != '%') {
- qstring_append_chr(qstring, *p++);
- } else if (*(p + 1) == '%') {
- qstring_append_chr(qstring, '%');
- p += 2;
- } else {
- p = append_field(error, qstring, entry, p);
- }
- }
-
- return qstring;
-}
-
-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++) {
- if (strcmp(qerror_table[i].error_fmt, fmt) == 0) {
- entry = &qerror_table[i];
- break;
- }
- }
-
- qstr = qerror_format_desc(error, entry);
- ret = g_strdup(qstring_get_str(qstr));
- QDECREF(qstr);
-
- return ret;
-}
-
/**
* qerror_human(): Format QError data into human-readable string.
*/
diff --git a/qerror.h b/qerror.h
index 32e9a22..10d83d8 100644
--- a/qerror.h
+++ b/qerror.h
@@ -19,11 +19,6 @@
#include "error.h"
#include <stdarg.h>
-typedef struct QErrorStringTable {
- const char *desc;
- const char *error_fmt;
-} QErrorStringTable;
-
typedef struct QError {
QObject_HEAD;
QDict *error;
@@ -35,7 +30,6 @@ QString *qerror_human(const QError *qerror);
void qerror_report(int err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
void qerror_report_err(Error *err);
void assert_no_error(Error *err);
-char *qerror_format(const char *fmt, QDict *error);
QDict *build_error_dict(int err_class, const char *msg);
#endif /* QERROR_H */
diff --git a/scripts/qapi-errors.py b/scripts/qapi-errors.py
index 5f8723e..dc656f2 100644
--- a/scripts/qapi-errors.py
+++ b/scripts/qapi-errors.py
@@ -62,29 +62,6 @@ def gen_error_macro(err_domain):
string += cur
return 'QERR_' + string.upper()
-def gen_error_def_table(exprs):
- ret = mcgen('''
-static const QErrorStringTable qerror_table[] = {
-''')
-
- for err in exprs:
- macro = gen_error_macro(err['error'])
- desc = err['description']
- ret += mcgen('''
- {
- .error_fmt = %(error_macro)s,
- .desc = "%(error_desc)s",
- },
-''',
- error_macro=macro, error_desc=desc)
-
- ret += mcgen('''
- {}
-};
-''')
-
- return ret
-
def gen_error_data_obj(data):
colon = ''
data_str = ''
@@ -206,9 +183,6 @@ if __name__ == '__main__':
ret = gen_error_def_prologue(error_header=h_file, prefix=prefix)
fdef.write(ret)
- ret = gen_error_def_table(exprs)
- fdef.write(ret)
-
ret = gen_error_obj_table(exprs)
fdef.write(ret)
--
1.7.11.2.249.g31c7954.dirty
- Re: [Qemu-devel] [PATCH 03/14] qerror: drop qerror_abort(), (continued)
- [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, 2012/07/25
- [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 <=
- [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
- [Qemu-devel] [PATCH 14/14] error: change all error_set() calls to use the ErrClass enum, Luiz Capitulino, 2012/07/25
- Re: [Qemu-devel] [RFC 00/14]: add printf-like human msg to error_set(), Anthony Liguori, 2012/07/25