Skip to content

Commit c6f5d40

Browse files
philmdMarkus Armbruster
authored andcommitted
qapi: Inline and remove QERR_INVALID_PARAMETER definition
Address the comment added in commit 4629ed1 ("qerror: Finally unused, clean up"), from 2015: /* * These macros will go away, please don't use * in new code, and do not add new ones! */ Mechanical transformation using: $ sed -i -e "s/QERR_INVALID_PARAMETER,/\"Invalid parameter '%s'\",/" \ $(git grep -lw QERR_INVALID_PARAMETER) Manually simplify qemu_opts_create(), and remove the macro definition in include/qapi/qmp/qerror.h. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Markus Armbruster <[email protected]> Message-ID: <[email protected]>
1 parent f95b25c commit c6f5d40

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

include/qapi/qmp/qerror.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
* add new ones!
1818
*/
1919

20-
#define QERR_INVALID_PARAMETER \
21-
"Invalid parameter '%s'"
22-
2320
#define QERR_INVALID_PARAMETER_TYPE \
2421
"Invalid parameter type for '%s', expected: %s"
2522

qapi/opts-visitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ opts_check_struct(Visitor *v, Error **errp)
184184
const QemuOpt *first;
185185

186186
first = g_queue_peek_head(any);
187-
error_setg(errp, QERR_INVALID_PARAMETER, first->name);
187+
error_setg(errp, "Invalid parameter '%s'", first->name);
188188
return false;
189189
}
190190
return true;

util/qemu-option.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static bool opt_validate(QemuOpt *opt, Error **errp)
498498

499499
desc = find_desc_by_name(list->desc, opt->name);
500500
if (!desc && !opts_accepts_any(list)) {
501-
error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
501+
error_setg(errp, "Invalid parameter '%s'", opt->name);
502502
return false;
503503
}
504504

@@ -531,7 +531,7 @@ bool qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
531531

532532
desc = find_desc_by_name(list->desc, name);
533533
if (!desc && !opts_accepts_any(list)) {
534-
error_setg(errp, QERR_INVALID_PARAMETER, name);
534+
error_setg(errp, "Invalid parameter '%s'", name);
535535
return false;
536536
}
537537

@@ -554,7 +554,7 @@ bool qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
554554

555555
desc = find_desc_by_name(list->desc, name);
556556
if (!desc && !opts_accepts_any(list)) {
557-
error_setg(errp, QERR_INVALID_PARAMETER, name);
557+
error_setg(errp, "Invalid parameter '%s'", name);
558558
return false;
559559
}
560560

@@ -612,7 +612,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
612612

613613
if (list->merge_lists) {
614614
if (id) {
615-
error_setg(errp, QERR_INVALID_PARAMETER, "id");
615+
error_setg(errp, "Invalid parameter 'id'");
616616
return NULL;
617617
}
618618
opts = qemu_opts_find(list, NULL);
@@ -1103,7 +1103,7 @@ bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
11031103
QTAILQ_FOREACH(opt, &opts->head, next) {
11041104
opt->desc = find_desc_by_name(desc, opt->name);
11051105
if (!opt->desc) {
1106-
error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
1106+
error_setg(errp, "Invalid parameter '%s'", opt->name);
11071107
return false;
11081108
}
11091109

0 commit comments

Comments
 (0)