mirror of
https://github.com/mii443/qemu.git
synced 2025-12-09 22:18:23 +00:00
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.
Clean up as follows:
* 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.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
@@ -132,7 +132,8 @@ static void parse_option_bool(const char *name, const char *value, bool *ret,
|
||||
} else if (!strcmp(value, "off")) {
|
||||
*ret = 0;
|
||||
} else {
|
||||
error_set(errp,QERR_INVALID_PARAMETER_VALUE, name, "'on' or 'off'");
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
|
||||
name, "'on' or 'off'");
|
||||
}
|
||||
} else {
|
||||
*ret = 1;
|
||||
@@ -148,12 +149,12 @@ static void parse_option_number(const char *name, const char *value,
|
||||
if (value != NULL) {
|
||||
number = strtoull(value, &postfix, 0);
|
||||
if (*postfix != '\0') {
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
|
||||
return;
|
||||
}
|
||||
*ret = number;
|
||||
} else {
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +199,7 @@ void parse_option_size(const char *name, const char *value,
|
||||
*ret = (uint64_t) sizef;
|
||||
break;
|
||||
default:
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
|
||||
#if 0 /* conversion from qerror_report() to error_set() broke this: */
|
||||
error_printf_unless_qmp("You may use k, M, G or T suffixes for "
|
||||
"kilobytes, megabytes, gigabytes and terabytes.\n");
|
||||
@@ -206,7 +207,7 @@ void parse_option_size(const char *name, const char *value,
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,7 +528,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,
|
||||
|
||||
desc = find_desc_by_name(opts->list->desc, name);
|
||||
if (!desc && !opts_accepts_any(opts)) {
|
||||
error_set(errp, QERR_INVALID_PARAMETER, name);
|
||||
error_setg(errp, QERR_INVALID_PARAMETER, name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -563,7 +564,7 @@ void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
|
||||
opt = g_malloc0(sizeof(*opt));
|
||||
opt->desc = find_desc_by_name(desc, name);
|
||||
if (!opt->desc && !opts_accepts_any(opts)) {
|
||||
error_set(errp, QERR_INVALID_PARAMETER, name);
|
||||
error_setg(errp, QERR_INVALID_PARAMETER, name);
|
||||
g_free(opt);
|
||||
return;
|
||||
}
|
||||
@@ -584,7 +585,7 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
|
||||
opt = g_malloc0(sizeof(*opt));
|
||||
opt->desc = find_desc_by_name(desc, name);
|
||||
if (!opt->desc && !opts_accepts_any(opts)) {
|
||||
error_set(errp, QERR_INVALID_PARAMETER, name);
|
||||
error_setg(errp, QERR_INVALID_PARAMETER, name);
|
||||
g_free(opt);
|
||||
return;
|
||||
}
|
||||
@@ -640,7 +641,8 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
|
||||
|
||||
if (id) {
|
||||
if (!id_wellformed(id)) {
|
||||
error_set(errp,QERR_INVALID_PARAMETER_VALUE, "id", "an identifier");
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id",
|
||||
"an identifier");
|
||||
#if 0 /* conversion from qerror_report() to error_set() broke this: */
|
||||
error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n");
|
||||
#endif
|
||||
@@ -1055,7 +1057,7 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
|
||||
QTAILQ_FOREACH(opt, &opts->head, next) {
|
||||
opt->desc = find_desc_by_name(desc, opt->name);
|
||||
if (!opt->desc) {
|
||||
error_set(errp, QERR_INVALID_PARAMETER, opt->name);
|
||||
error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user