qerror: Clean up QERR_ macros to expand into a single string

These macros expand into error class enumeration constant, comma,
string. Unclean. Has been that way since commit 13f59ae.

The error class is always ERROR_CLASS_GENERIC_ERROR since the previous
commit.

* Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and
delete it from the QERR_ macro. No change after preprocessing.

* Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into
error_setg(...). Again, no change after preprocessing.

Backports commit c6bd8c706a799eb0fece99f468aaa22b818036f3 from qemu
This commit is contained in:
Markus Armbruster 2018-02-13 17:34:32 -05:00 committed by Lioncash
parent 349447b324
commit 76c16a46c7
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
7 changed files with 95 additions and 95 deletions

View file

@ -163,7 +163,7 @@ static int device_set_realized(struct uc_struct *uc, Object *obj, bool value, Er
Error *local_err = NULL;
if (dev->hotplugged && !dc->hotpluggable) {
error_set(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
error_setg(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
return -1;
}

View file

@ -33,120 +33,120 @@ void qerror_report_err(Error *err);
* Use scripts/check-qerror.sh to check.
*/
#define QERR_BASE_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
"Base '%s' not found"
#define QERR_BLOCK_JOB_NOT_ACTIVE \
ERROR_CLASS_DEVICE_NOT_ACTIVE, "No active block job on device '%s'"
"No active block job on device '%s'"
#define QERR_BLOCK_JOB_NOT_READY \
ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed"
"The active block job for device '%s' cannot be completed"
#define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'"
"Block format '%s' used by device '%s' does not support feature '%s'"
#define QERR_BUS_NO_HOTPLUG \
ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
"Bus '%s' does not support hotplugging"
#define QERR_BUS_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
"Bus '%s' not found"
#define QERR_COMMAND_NOT_FOUND \
ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found"
"The command %s has not been found"
#define QERR_DEVICE_ENCRYPTED \
ERROR_CLASS_DEVICE_ENCRYPTED, "'%s' (%s) is encrypted"
"'%s' (%s) is encrypted"
#define QERR_DEVICE_HAS_NO_MEDIUM \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
"Device '%s' has no medium"
#define QERR_DEVICE_INIT_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized"
"Device '%s' could not be initialized"
#define QERR_DEVICE_IN_USE \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use"
"Device '%s' is in use"
#define QERR_DEVICE_IS_READ_ONLY \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only"
"Device '%s' is read only"
#define QERR_DEVICE_NO_HOTPLUG \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
"Device '%s' does not support hotplugging"
#define QERR_DEVICE_NOT_ACTIVE \
ERROR_CLASS_DEVICE_NOT_ACTIVE, "No %s device has been activated"
"No %s device has been activated"
#define QERR_DEVICE_NOT_ENCRYPTED \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted"
"Device '%s' is not encrypted"
#define QERR_FD_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
"File descriptor named '%s' not found"
#define QERR_FD_NOT_SUPPLIED \
ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS"
"No file descriptor supplied via SCM_RIGHTS"
#define QERR_FEATURE_DISABLED \
ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled"
"The feature '%s' is not enabled"
#define QERR_INVALID_BLOCK_FORMAT \
ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
"Invalid block format '%s'"
#define QERR_INVALID_PARAMETER \
ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
"Invalid parameter '%s'"
#define QERR_INVALID_PARAMETER_TYPE \
ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
"Invalid parameter type for '%s', expected: %s"
#define QERR_INVALID_PARAMETER_VALUE \
ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s"
"Parameter '%s' expects %s"
#define QERR_INVALID_PASSWORD \
ERROR_CLASS_GENERIC_ERROR, "Password incorrect"
"Password incorrect"
#define QERR_IO_ERROR \
ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
"An IO error has occurred"
#define QERR_JSON_PARSING \
ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
"Invalid JSON syntax"
#define QERR_KVM_MISSING_CAP \
ERROR_CLASS_KVM_MISSING_CAP, "Using KVM without %s, %s unavailable"
"Using KVM without %s, %s unavailable"
#define QERR_MIGRATION_ACTIVE \
ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
"There's a migration process in progress"
#define QERR_MISSING_PARAMETER \
ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
"Parameter '%s' is missing"
#define QERR_PERMISSION_DENIED \
ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
"Insufficient permission to perform this operation"
#define QERR_PROPERTY_VALUE_BAD \
ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
"Property '%s.%s' doesn't take value '%s'"
#define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
"Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
#define QERR_QGA_COMMAND_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
"Guest agent command failed, error was '%s'"
#define QERR_QMP_BAD_INPUT_OBJECT \
ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
"Expected '%s' in QMP input"
#define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'"
"QMP input object member '%s' expects '%s'"
#define QERR_QMP_EXTRA_MEMBER \
ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
"QMP input object member '%s' is unexpected"
#define QERR_SET_PASSWD_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Could not set password"
"Could not set password"
#define QERR_UNDEFINED_ERROR \
ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
"An undefined error has occurred"
#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s"
"'%s' uses a %s feature which is not supported by this qemu version: %s"
#define QERR_UNSUPPORTED \
ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
"this feature or command is not currently supported"
#endif /* QERROR_H */

View file

@ -110,8 +110,8 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < 0 || value > UINT8_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"uint8_t");
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", "uint8_t");
return;
}
*obj = (uint8_t)value;
@ -128,8 +128,8 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp
value = *obj;
v->type_int(v, &value, name, errp);
if (value < 0 || value > UINT16_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"uint16_t");
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", "uint16_t");
return;
}
*obj = (uint16_t)value;
@ -146,8 +146,8 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp
value = *obj;
v->type_int(v, &value, name, errp);
if (value < 0 || value > UINT32_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"uint32_t");
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", "uint32_t");
return;
}
*obj = (uint32_t)value;
@ -177,8 +177,8 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT8_MIN || value > INT8_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"int8_t");
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", "int8_t");
return;
}
*obj = (int8_t)value;
@ -195,8 +195,8 @@ void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT16_MIN || value > INT16_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"int16_t");
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", "int16_t");
return;
}
*obj = (int16_t)value;
@ -213,8 +213,8 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT32_MIN || value > INT32_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"int32_t");
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
name ? name : "null", "int32_t");
return;
}
*obj = (int32_t)value;
@ -271,7 +271,7 @@ void output_type_enum(Visitor *v, int *obj, const char *strings[],
assert(strings);
while (strings[i++] != NULL);
if (value < 0 || value >= i - 1) {
error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null");
error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null");
return;
}
@ -303,7 +303,7 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[],
}
if (strings[value] == NULL) {
error_set(errp, QERR_INVALID_PARAMETER, enum_str);
error_setg(errp, QERR_INVALID_PARAMETER, enum_str);
g_free(enum_str);
return;
}

View file

@ -105,7 +105,7 @@ static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
if (g_hash_table_size(top_ht)) {
const char *key;
g_hash_table_find(top_ht, always_true, (gpointer)&key);
error_set(errp, QERR_QMP_EXTRA_MEMBER, key);
error_setg(errp, QERR_QMP_EXTRA_MEMBER, key);
}
g_hash_table_unref(top_ht);
}
@ -122,8 +122,8 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,
Error *err = NULL;
if (!qobj || qobject_type(qobj) != QTYPE_QDICT) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"QDict");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"QDict");
return;
}
@ -163,8 +163,8 @@ static void qmp_input_start_list(Visitor *v, const char *name, Error **errp)
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QLIST) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"list");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"list");
return;
}
@ -215,7 +215,7 @@ static void qmp_input_get_next_type(Visitor *v, int *kind, const int *qobjects,
QObject *qobj = qmp_input_get_object(qiv, name, false);
if (!qobj) {
error_set(errp, QERR_MISSING_PARAMETER, name ? name : "null");
error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
return;
}
*kind = qobjects[qobject_type(qobj)];
@ -228,8 +228,8 @@ static void qmp_input_type_int(Visitor *v, int64_t *obj, const char *name,
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QINT) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
@ -243,8 +243,8 @@ static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QBOOL) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"boolean");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"boolean");
return;
}
@ -258,8 +258,8 @@ static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QSTRING) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"string");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"string");
return;
}
@ -274,8 +274,8 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
if (!qobj || (qobject_type(qobj) != QTYPE_QFLOAT &&
qobject_type(qobj) != QTYPE_QINT)) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
return;
}

View file

@ -185,8 +185,8 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name,
StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
if (!siv->string) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
@ -217,8 +217,8 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name,
return;
error:
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
"an int64 value or range");
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
"an int64 value or range");
}
static void parse_type_bool(Visitor *v, bool *obj, const char *name,
@ -241,8 +241,8 @@ static void parse_type_bool(Visitor *v, bool *obj, const char *name,
}
}
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"boolean");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"boolean");
}
static void parse_type_str(Visitor *v, char **obj, const char *name,
@ -252,8 +252,8 @@ static void parse_type_str(Visitor *v, char **obj, const char *name,
if (siv->string) {
*obj = g_strdup(siv->string);
} else {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"string");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"string");
}
}
@ -269,8 +269,8 @@ static void parse_type_number(Visitor *v, double *obj, const char *name,
val = strtod(siv->string, &endp);
}
if (!siv->string || errno || endp == siv->string || *endp) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
return;
}

View file

@ -808,7 +808,7 @@ void object_property_get(struct uc_struct *uc, Object *obj, Visitor *v, const ch
}
if (!prop->get) {
error_set(errp, QERR_PERMISSION_DENIED);
error_setg(errp, QERR_PERMISSION_DENIED);
} else {
prop->get(uc, obj, v, prop->opaque, name, errp);
}
@ -823,10 +823,10 @@ void object_property_set(struct uc_struct *uc, Object *obj, Visitor *v, const ch
}
if (!prop->set) {
error_set(errp, QERR_PERMISSION_DENIED);
error_setg(errp, QERR_PERMISSION_DENIED);
} else {
if (prop->set(uc, obj, v, prop->opaque, name, errp))
error_set(errp, QERR_UNDEFINED_ERROR);
error_setg(errp, QERR_UNDEFINED_ERROR);
}
}
@ -851,7 +851,7 @@ char *object_property_get_str(struct uc_struct *uc, Object *obj, const char *nam
}
qstring = qobject_to_qstring(ret);
if (!qstring) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
retval = NULL;
} else {
retval = g_strdup(qstring_get_str(qstring));
@ -912,7 +912,7 @@ bool object_property_get_bool(struct uc_struct *uc, Object *obj, const char *nam
}
qbool = qobject_to_qbool(ret);
if (!qbool) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
retval = false;
} else {
retval = qbool_get_bool(qbool);
@ -943,7 +943,7 @@ int64_t object_property_get_int(struct uc_struct *uc, Object *obj, const char *n
}
qint = qobject_to_qint(ret);
if (!qint) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
retval = -1;
} else {
retval = qint_get_int(qint);
@ -1096,7 +1096,7 @@ static Object *object_resolve_link(struct uc_struct *uc, Object *obj, const char
} else if (!target) {
target = object_resolve_path(uc, path, &ambiguous);
if (target || ambiguous) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
} else {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", path);

View file

@ -1262,8 +1262,8 @@ static int x86_cpuid_version_set_family(struct uc_struct *uc, Object *obj, Visit
return -1;
}
if (value < min || value > max) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
return -1;
}
@ -1305,8 +1305,8 @@ static int x86_cpuid_version_set_model(struct uc_struct *uc, Object *obj, Visito
return -1;
}
if (value < min || value > max) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
return -1;
}
@ -1345,8 +1345,8 @@ static int x86_cpuid_version_set_stepping(struct uc_struct *uc, Object *obj, Vis
return -1;
}
if (value < min || value > max) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
return -1;
}
@ -1376,8 +1376,8 @@ static int x86_cpuid_set_vendor(struct uc_struct *uc, Object *obj, const char *v
int i;
if (strlen(value) != CPUID_VENDOR_SZ) {
error_set(errp, QERR_PROPERTY_VALUE_BAD, "",
"vendor", value);
error_setg(errp, QERR_PROPERTY_VALUE_BAD, "",
"vendor", value);
return -1;
}
@ -1457,8 +1457,8 @@ static int x86_cpuid_set_tsc_freq(struct uc_struct *uc, Object *obj, Visitor *v,
return -1;
}
if (value < min || value > max) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
name ? name : "null", value, min, max);
return -1;
}