qerror: Eliminate QERR_DEVICE_NOT_FOUND

Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used
in new code.  Hiding them in QERR_ macros makes new uses hard to spot.
Fortunately, there's just one such macro left.  Eliminate it with this
coccinelle semantic patch:

    @@
    expression EP, E;
    @@
    -error_set(EP, QERR_DEVICE_NOT_FOUND, E)
    +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Markus Armbruster
2015-03-16 08:57:47 +01:00
parent c6bf0f7ffa
commit 75158ebbe2
10 changed files with 52 additions and 29 deletions

View File

@@ -457,7 +457,8 @@ static BusState *qbus_find(const char *path, Error **errp)
pos += len;
dev = qbus_find_dev(bus, elem);
if (!dev) {
error_set(errp, QERR_DEVICE_NOT_FOUND, elem);
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", elem);
#if 0 /* conversion from qerror_report() to error_set() broke this: */
if (!monitor_cur_is_qmp()) {
qbus_list_dev(bus);
@@ -793,7 +794,8 @@ void qmp_device_del(const char *id, Error **errp)
g_free(path);
if (!obj) {
error_set(errp, QERR_DEVICE_NOT_FOUND, id);
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", id);
return;
}