[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/35] qerror: drop qerror_abort()
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 05/35] qerror: drop qerror_abort() |
Date: |
Tue, 7 Aug 2012 12:53:16 -0300 |
qerror_abort() depends on the 'file', 'func' and 'linenr' members of
QError. However, these members are going to be dropped by the next
commit, so let's drop qerror_abort() in favor of printing an error
message to stderr plus a call to abort().
Signed-off-by: Luiz Capitulino <address@hidden>
---
qerror.c | 41 ++++++++++++++---------------------------
1 file changed, 14 insertions(+), 27 deletions(-)
diff --git a/qerror.c b/qerror.c
index bfb875a..7cb7c12 100644
--- a/qerror.c
+++ b/qerror.c
@@ -346,22 +346,6 @@ static QError *qerror_new(void)
return qerr;
}
-static void GCC_FMT_ATTR(2, 3) qerror_abort(const QError *qerr,
- const char *fmt, ...)
-{
- va_list ap;
-
- fprintf(stderr, "qerror: bad call in function '%s':\n", qerr->func);
- fprintf(stderr, "qerror: -> ");
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
-
- fprintf(stderr, "\nqerror: call at %s:%d\n", qerr->file, qerr->linenr);
- abort();
-}
-
static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError *qerr,
const char *fmt, va_list *va)
{
@@ -369,28 +353,34 @@ static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError
*qerr,
obj = qobject_from_jsonv(fmt, va);
if (!obj) {
- qerror_abort(qerr, "invalid format '%s'", fmt);
+ fprintf(stderr, "invalid json in error dict '%s'\n", fmt);
+ abort();
}
if (qobject_type(obj) != QTYPE_QDICT) {
- qerror_abort(qerr, "error format is not a QDict '%s'", fmt);
+ fprintf(stderr, "error is not a dict '%s'\n", fmt);
+ abort();
}
qerr->error = qobject_to_qdict(obj);
obj = qdict_get(qerr->error, "class");
if (!obj) {
- qerror_abort(qerr, "missing 'class' key in '%s'", fmt);
+ fprintf(stderr, "missing 'class' key in '%s'\n", fmt);
+ abort();
}
if (qobject_type(obj) != QTYPE_QSTRING) {
- qerror_abort(qerr, "'class' key value should be a QString");
+ fprintf(stderr, "'class' key value should be a string in '%s'\n", fmt);
+ abort();
}
obj = qdict_get(qerr->error, "data");
if (!obj) {
- qerror_abort(qerr, "missing 'data' key in '%s'", fmt);
+ fprintf(stderr, "missing 'data' key in '%s'\n", fmt);
+ abort();
}
if (qobject_type(obj) != QTYPE_QDICT) {
- qerror_abort(qerr, "'data' key value should be a QDICT");
+ fprintf(stderr, "'data' key value should be a dict in '%s'\n", fmt);
+ abort();
}
}
@@ -407,7 +397,8 @@ static void qerror_set_desc(QError *qerr, const char *fmt)
}
}
- qerror_abort(qerr, "error format '%s' not found", fmt);
+ fprintf(stderr, "error format '%s' not found\n", fmt);
+ abort();
}
/**
@@ -435,10 +426,6 @@ static QError *qerror_from_info(const char *file, int
linenr, const char *func,
qerr->file = file;
qerr->func = func;
- if (!fmt) {
- qerror_abort(qerr, "QDict not specified");
- }
-
qerror_set_data(qerr, fmt, va);
qerror_set_desc(qerr, fmt);
--
1.7.11.2.249.g31c7954.dirty
- [Qemu-devel] [PATCH v2 00/35]: add new error format, Luiz Capitulino, 2012/08/07
- [Qemu-devel] [PATCH 05/35] qerror: drop qerror_abort(),
Luiz Capitulino <=
- [Qemu-devel] [PATCH 07/35] qerror: QError: drop file, linenr, func, Luiz Capitulino, 2012/08/07
- [Qemu-devel] [PATCH 12/35] hmp: hmp_cont(): don't rely on QERR_DEVICE_ENCRYPTED, Luiz Capitulino, 2012/08/07
- [Qemu-devel] [PATCH 02/35] qerror: QERR_AMBIGUOUS_PATH: drop %(object) from human msg, Luiz Capitulino, 2012/08/07
- [Qemu-devel] [PATCH 09/35] qerror: don't delay error message construction, Luiz Capitulino, 2012/08/07
- [Qemu-devel] [PATCH 13/35] hmp_change(): don't access DeviceEncrypted's data, Luiz Capitulino, 2012/08/07
- [Qemu-devel] [PATCH 20/35] qapi: generate correct enum names for camel case enums, Luiz Capitulino, 2012/08/07
- [Qemu-devel] [PATCH 17/35] block: block_int: include qerror.h, Luiz Capitulino, 2012/08/07