Skip to content

Commit

Permalink
qerror: QError: drop file, linenr, func
Browse files Browse the repository at this point in the history
They have never been fully used and conflict with future error
improvements.

Also makes qerror_report() a proper function, as there's no point
in having it as a macro anymore.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
  • Loading branch information
Luiz Capitulino committed Aug 13, 2012
1 parent f2dd1d6 commit 5f0f0e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
20 changes: 3 additions & 17 deletions qerror.c
Expand Up @@ -404,27 +404,14 @@ static const QErrorStringTable *get_desc_no_fail(const char *fmt)
/**
* qerror_from_info(): Create a new QError from error information
*
* The information consists of:
*
* - file the file name of where the error occurred
* - linenr the line number of where the error occurred
* - func the function name of where the error occurred
* - fmt JSON printf-like dictionary, there must exist keys 'class' and
* 'data'
* - va va_list of all arguments specified by fmt
*
* Return strong reference.
*/
static QError *qerror_from_info(const char *file, int linenr, const char *func,
const char *fmt, va_list *va)
static QError *qerror_from_info(const char *fmt, va_list *va)
{
QError *qerr;

qerr = qerror_new();
loc_save(&qerr->loc);
qerr->linenr = linenr;
qerr->file = file;
qerr->func = func;

qerr->error = error_obj_from_fmt_no_fail(fmt, va);
qerr->entry = get_desc_no_fail(fmt);
Expand Down Expand Up @@ -545,14 +532,13 @@ static void qerror_print(QError *qerror)
QDECREF(qstring);
}

void qerror_report_internal(const char *file, int linenr, const char *func,
const char *fmt, ...)
void qerror_report(const char *fmt, ...)
{
va_list va;
QError *qerror;

va_start(va, fmt);
qerror = qerror_from_info(file, linenr, func, fmt, &va);
qerror = qerror_from_info(fmt, &va);
va_end(va);

if (monitor_cur_is_qmp()) {
Expand Down
8 changes: 1 addition & 7 deletions qerror.h
Expand Up @@ -27,20 +27,14 @@ typedef struct QError {
QObject_HEAD;
QDict *error;
Location loc;
int linenr;
const char *file;
const char *func;
const QErrorStringTable *entry;
} QError;

QString *qerror_human(const QError *qerror);
void qerror_report_internal(const char *file, int linenr, const char *func,
const char *fmt, ...) GCC_FMT_ATTR(4, 5);
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);
#define qerror_report(fmt, ...) \
qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)

/*
* QError class list
Expand Down

0 comments on commit 5f0f0e1

Please sign in to comment.