Commit a8cb2d30 authored by Luiz Capitulino's avatar Luiz Capitulino
Browse files

error: drop unused functions



Besides being unused, they operate on the current error format,
which is going to be replaced soon.

Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent ab878ddf
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
@@ -74,29 +74,6 @@ const char *error_get_pretty(Error *err)
    return err->msg;
}

const char *error_get_field(Error *err, const char *field)
{
    if (strcmp(field, "class") == 0) {
        return qdict_get_str(err->obj, field);
    } else {
        QDict *dict = qdict_get_qdict(err->obj, "data");
        return qdict_get_str(dict, field);
    }
}

QDict *error_get_data(Error *err)
{
    QDict *data = qdict_get_qdict(err->obj, "data");
    QINCREF(data);
    return data;
}

void error_set_field(Error *err, const char *field, const char *value)
{
    QDict *dict = qdict_get_qdict(err->obj, "data");
    qdict_put(dict, field, qstring_from_str(value));
}

void error_free(Error *err)
{
    if (err) {
@@ -106,31 +83,6 @@ void error_free(Error *err)
    }
}

bool error_is_type(Error *err, ErrorClass err_class, const char *fmt)
{
    const char *error_class;
    char *ptr;
    char *end;

    if (!err) {
        return false;
    }

    ptr = strstr(fmt, "'class': '");
    assert(ptr != NULL);
    ptr += strlen("'class': '");

    end = strchr(ptr, '\'');
    assert(end != NULL);

    error_class = error_get_field(err, "class");
    if (strlen(error_class) != end - ptr) {
        return false;
    }

    return strncmp(ptr, error_class, end - ptr) == 0;
}

void error_propagate(Error **dst_err, Error *local_err)
{
    if (dst_err && !*dst_err) {
+0 −16
Original line number Diff line number Diff line
@@ -50,16 +50,6 @@ Error *error_copy(const Error *err);
 */
const char *error_get_pretty(Error *err);

/**
 * Get an individual named error field.
 */
const char *error_get_field(Error *err, const char *field);

/**
 * Get an individual named error field.
 */
void error_set_field(Error *err, const char *field, const char *value);

/**
 * Propagate an error to an indirect pointer to an error.  This function will
 * always transfer ownership of the error reference and handles the case where
@@ -72,10 +62,4 @@ void error_propagate(Error **dst_err, Error *local_err);
 */
void error_free(Error *err);

/**
 * Determine if an error is of a speific type (based on the qerror format).
 * Non-QEMU users should get the `class' field to identify the error type.
 */
bool error_is_type(Error *err, ErrorClass err_class, const char *fmt);

#endif
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
 *
 * These are used to convert QErrors to Errors
 */
QDict *error_get_data(Error *err);
QObject *error_get_qobject(Error *err);
void error_set_qobject(Error **errp, QObject *obj);