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)

Backports commit 75158ebbe259f0bd8bf435e8f4827a43ec89c877 from qemu
This commit is contained in:
Markus Armbruster 2018-02-13 17:23:09 -05:00 committed by Lioncash
parent c749554a75
commit 349447b324
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 4 additions and 5 deletions

View file

@ -77,9 +77,6 @@ void qerror_report_err(Error *err);
#define QERR_DEVICE_NOT_ENCRYPTED \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted"
#define QERR_DEVICE_NOT_FOUND \
ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
#define QERR_FD_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"

View file

@ -882,7 +882,8 @@ Object *object_property_get_link(struct uc_struct *uc, Object *obj, const char *
if (str && *str) {
target = object_resolve_path(uc, str, NULL);
if (!target) {
error_set(errp, QERR_DEVICE_NOT_FOUND, str);
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", str);
}
}
@ -1097,7 +1098,8 @@ static Object *object_resolve_link(struct uc_struct *uc, Object *obj, const char
if (target || ambiguous) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
} else {
error_set(errp, QERR_DEVICE_NOT_FOUND, path);
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", path);
}
target = NULL;
}