qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 08/11] qerror: Finally unused, clean up


From: Markus Armbruster
Subject: [Qemu-devel] [PATCH v2 08/11] qerror: Finally unused, clean up
Date: Tue, 16 Jun 2015 16:21:44 +0200

Remove it except for two things in qerror.h:

* Two #include to be cleaned up separately to avoid cluttering this
  patch.

* The QERR_ macros.  Mark as obsolete.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Luiz Capitulino <address@hidden>
---
 block/qapi.c               |   6 --
 include/monitor/monitor.h  |   1 -
 include/qapi/qmp/qerror.h  |  19 +-----
 include/qapi/qmp/qobject.h |   1 -
 monitor.c                  |  13 ----
 qobject/Makefile.objs      |   1 -
 qobject/qerror.c           | 148 ---------------------------------------------
 qobject/qjson.c            |   3 -
 stubs/Makefile.objs        |   1 -
 stubs/mon-is-qmp.c         |   2 +
 stubs/mon-set-error.c      |   8 ---
 11 files changed, 4 insertions(+), 199 deletions(-)
 delete mode 100644 qobject/qerror.c
 delete mode 100644 stubs/mon-set-error.c

diff --git a/block/qapi.c b/block/qapi.c
index a738148..e130562 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -523,12 +523,6 @@ static void dump_qobject(fprintf_function func_fprintf, 
void *f,
             func_fprintf(f, "%s", qbool_get_int(value) ? "true" : "false");
             break;
         }
-        case QTYPE_QERROR: {
-            QString *value = qerror_human((QError *)obj);
-            func_fprintf(f, "%s", qstring_get_str(value));
-            QDECREF(value);
-            break;
-        }
         default:
             abort();
     }
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 33c28a4..aa83104 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -39,7 +39,6 @@ void monitor_flush(Monitor *mon);
 int monitor_set_cpu(int cpu_index);
 int monitor_get_cpu_index(void);
 
-void monitor_set_error(Monitor *mon, QError *qerror);
 void monitor_read_command(Monitor *mon, int show_prompt);
 int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
                           void *opaque);
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index e34741e..f8182c7 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -14,25 +14,10 @@
 
 #include "qapi/qmp/qstring.h"
 #include "qemu/error-report.h"
-#include "qapi/error.h"
-#include "qapi-types.h"
-#include <stdarg.h>
-
-typedef struct QError {
-    QObject_HEAD;
-    Location loc;
-    char *err_msg;
-    ErrorClass err_class;
-} QError;
-
-QString *qerror_human(const QError *qerror);
-void qerror_report(ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 
3);
-void qerror_report_err(Error *err);
 
 /*
- * QError class list
- * Please keep the definitions in alphabetical order.
- * Use scripts/check-qerror.sh to check.
+ * These macros will go away, please don't use in new code, and do not
+ * add new ones!
  */
 #define QERR_BASE_NOT_FOUND \
     "Base '%s' not found"
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index 84b2d9f..260d2ed 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -44,7 +44,6 @@ typedef enum {
     QTYPE_QLIST,
     QTYPE_QFLOAT,
     QTYPE_QBOOL,
-    QTYPE_QERROR,
     QTYPE_MAX,
 } qtype_code;
 
diff --git a/monitor.c b/monitor.c
index 8b84547..eb32f3b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -205,7 +205,6 @@ struct Monitor {
     BlockCompletionFunc *password_completion_cb;
     void *password_opaque;
     mon_cmd_t *cmd_table;
-    QError *error;
     QLIST_HEAD(,mon_fd_t) fds;
     QLIST_ENTRY(Monitor) entry;
 };
@@ -4040,16 +4039,6 @@ fail:
     return NULL;
 }
 
-void monitor_set_error(Monitor *mon, QError *qerror)
-{
-    /* report only the first error */
-    if (!mon->error) {
-        mon->error = qerror;
-    } else {
-        QDECREF(qerror);
-    }
-}
-
 static void handle_hmp_command(Monitor *mon, const char *cmdline)
 {
     QDict *qdict;
@@ -5054,8 +5043,6 @@ static void handle_qmp_command(JSONMessageParser *parser, 
QList *tokens)
 err_out:
     monitor_protocol_emitter(mon, data, local_err);
     qobject_decref(data);
-    QDECREF(mon->error);
-    mon->error = NULL;
     QDECREF(input);
     QDECREF(args);
 }
diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs
index f7595f5..0031e8b 100644
--- a/qobject/Makefile.objs
+++ b/qobject/Makefile.objs
@@ -1,3 +1,2 @@
 util-obj-y = qnull.o qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
 util-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
-util-obj-y += qerror.o
diff --git a/qobject/qerror.c b/qobject/qerror.c
deleted file mode 100644
index e3608e2..0000000
--- a/qobject/qerror.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * QError Module
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * Authors:
- *  Luiz Capitulino <address@hidden>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- */
-
-#include "monitor/monitor.h"
-#include "qapi/qmp/qjson.h"
-#include "qapi/qmp/qerror.h"
-#include "qemu-common.h"
-
-static void qerror_destroy_obj(QObject *obj);
-
-static const QType qerror_type = {
-    .code = QTYPE_QERROR,
-    .destroy = qerror_destroy_obj,
-};
-
-/**
- * qerror_new(): Create a new QError
- *
- * Return strong reference.
- */
-static QError *qerror_new(void)
-{
-    QError *qerr;
-
-    qerr = g_malloc0(sizeof(*qerr));
-    QOBJECT_INIT(qerr, &qerror_type);
-
-    return qerr;
-}
-
-/**
- * qerror_from_info(): Create a new QError from error information
- *
- * Return strong reference.
- */
-static QError * GCC_FMT_ATTR(2, 0)
-qerror_from_info(ErrorClass err_class, const char *fmt, va_list *va)
-{
-    QError *qerr;
-
-    qerr = qerror_new();
-    loc_save(&qerr->loc);
-
-    qerr->err_msg = g_strdup_vprintf(fmt, *va);
-    qerr->err_class = err_class;
-
-    return qerr;
-}
-
-/**
- * qerror_human(): Format QError data into human-readable string.
- */
-QString *qerror_human(const QError *qerror)
-{
-    return qstring_from_str(qerror->err_msg);
-}
-
-/**
- * qerror_print(): Print QError data
- *
- * This function will print the member 'desc' of the specified QError object,
- * it uses error_report() for this, so that the output is routed to the right
- * place (ie. stderr or Monitor's device).
- */
-static void qerror_print(QError *qerror)
-{
-    QString *qstring = qerror_human(qerror);
-    loc_push_restore(&qerror->loc);
-    error_report("%s", qstring_get_str(qstring));
-    loc_pop(&qerror->loc);
-    QDECREF(qstring);
-}
-
-void qerror_report(ErrorClass eclass, const char *fmt, ...)
-{
-    va_list va;
-    QError *qerror;
-
-    va_start(va, fmt);
-    qerror = qerror_from_info(eclass, fmt, &va);
-    va_end(va);
-
-    if (monitor_cur_is_qmp()) {
-        monitor_set_error(cur_mon, qerror);
-    } else {
-        qerror_print(qerror);
-        QDECREF(qerror);
-    }
-}
-
-/* Evil... */
-struct Error
-{
-    char *msg;
-    ErrorClass err_class;
-};
-
-void qerror_report_err(Error *err)
-{
-    QError *qerr;
-
-    qerr = qerror_new();
-    loc_save(&qerr->loc);
-    qerr->err_msg = g_strdup(err->msg);
-    qerr->err_class = err->err_class;
-
-    if (monitor_cur_is_qmp()) {
-        monitor_set_error(cur_mon, qerr);
-    } else {
-        qerror_print(qerr);
-        QDECREF(qerr);
-    }
-}
-
-/**
- * qobject_to_qerror(): Convert a QObject into a QError
- */
-static QError *qobject_to_qerror(const QObject *obj)
-{
-    if (qobject_type(obj) != QTYPE_QERROR) {
-        return NULL;
-    }
-
-    return container_of(obj, QError, base);
-}
-
-/**
- * qerror_destroy_obj(): Free all memory allocated by a QError
- */
-static void qerror_destroy_obj(QObject *obj)
-{
-    QError *qerr;
-
-    assert(obj != NULL);
-    qerr = qobject_to_qerror(obj);
-
-    g_free(qerr->err_msg);
-    g_free(qerr);
-}
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 846733d..3657c04 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -261,9 +261,6 @@ static void to_json(const QObject *obj, QString *str, int 
pretty, int indent)
         }
         break;
     }
-    case QTYPE_QERROR:
-        /* XXX: should QError be emitted? */
-        break;
     default:
         abort();
     }
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 8beff4c..9937a12 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -21,7 +21,6 @@ stub-obj-y += machine-init-done.o
 stub-obj-y += migr-blocker.o
 stub-obj-y += mon-is-qmp.o
 stub-obj-y += mon-printf.o
-stub-obj-y += mon-set-error.o
 stub-obj-y += monitor-init.o
 stub-obj-y += notify-event.o
 stub-obj-$(CONFIG_SPICE) += qemu-chr-open-spice.o
diff --git a/stubs/mon-is-qmp.c b/stubs/mon-is-qmp.c
index 1ef136a..dd26f19 100644
--- a/stubs/mon-is-qmp.c
+++ b/stubs/mon-is-qmp.c
@@ -1,6 +1,8 @@
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
+Monitor *cur_mon;
+
 bool monitor_cur_is_qmp(void)
 {
     return false;
diff --git a/stubs/mon-set-error.c b/stubs/mon-set-error.c
deleted file mode 100644
index d0411f9..0000000
--- a/stubs/mon-set-error.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "qemu-common.h"
-#include "monitor/monitor.h"
-
-Monitor *cur_mon;
-
-void monitor_set_error(Monitor *mon, QError *qerror)
-{
-}
-- 
1.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]