[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/13] qemu-option: opts_do_parse(): use error_set()
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 07/13] qemu-option: opts_do_parse(): use error_set() |
Date: |
Thu, 29 Mar 2012 14:26:37 -0300 |
The functions qemu_opts_do_parse() and opts_parse() both call
opts_do_parse(), but their callers expect QError semantics. Thus,
both functions call qerro_report_err() to keep the expected semantics.
Signed-off-by: Luiz Capitulino <address@hidden>
---
qemu-option.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/qemu-option.c b/qemu-option.c
index 38461d4..666eacd 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -848,12 +848,11 @@ int qemu_opts_print(QemuOpts *opts, void *dummy)
return 0;
}
-static int opts_do_parse(QemuOpts *opts, const char *params,
- const char *firstname, bool prepend)
+static void opts_do_parse(QemuOpts *opts, const char *params,
+ const char *firstname, bool prepend, Error **errp)
{
char option[128], value[1024];
const char *p,*pe,*pc;
- Error *local_err = NULL;
for (p = params; *p != '\0'; p++) {
pe = strchr(p, '=');
@@ -885,23 +884,29 @@ static int opts_do_parse(QemuOpts *opts, const char
*params,
}
if (strcmp(option, "id") != 0) {
/* store and parse */
- opt_set(opts, option, value, prepend, &local_err);
- if (error_is_set(&local_err)) {
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
+ opt_set(opts, option, value, prepend, errp);
+ if (error_is_set(errp)) {
+ return;
}
}
if (*p != ',') {
break;
}
}
- return 0;
}
int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char
*firstname)
{
- return opts_do_parse(opts, params, firstname, false);
+ Error *local_err = NULL;
+
+ opts_do_parse(opts, params, firstname, false, &local_err);
+ if (error_is_set(&local_err)) {
+ qerror_report_err(local_err);
+ error_free(local_err);
+ return -1;
+ }
+
+ return 0;
}
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
@@ -934,18 +939,23 @@ static QemuOpts *opts_parse(QemuOptsList *list, const
char *params,
}
if (opts == NULL) {
if (error_is_set(&local_err)) {
- qerror_report_err(local_err);
- error_free(local_err);
+ goto exit_err;
}
return NULL;
}
- if (opts_do_parse(opts, params, firstname, defaults) != 0) {
+ opts_do_parse(opts, params, firstname, defaults, &local_err);
+ if (error_is_set(&local_err)) {
qemu_opts_del(opts);
- return NULL;
+ goto exit_err;
}
return opts;
+
+exit_err:
+ qerror_report_err(local_err);
+ error_free(local_err);
+ return NULL;
}
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
--
1.7.9.2.384.g4a92a
- [Qemu-devel] [RFC 00/13]: convert device_add to the qapi, Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 01/13] qemu-option: qemu_opts_create(): use error_set(), Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 02/13] qemu-option: parse_option_number(): use error_set(), Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 07/13] qemu-option: opts_do_parse(): use error_set(),
Luiz Capitulino <=
- [Qemu-devel] [PATCH 04/13] qemu-option: parse_option_size(): use error_set(), Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 09/13] qerror: introduce QERR_INVALID_OPTION_GROUP, Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 06/13] qemu-option: opt_set(): use error_set(), Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 03/13] qemu-option: parse_option_bool(): use error_set(), Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 08/13] qemu-option: introduce qemu_opt_set_err(), Luiz Capitulino, 2012/03/29
- [Qemu-devel] [PATCH 12/13] qapi: support for keyworded variable-length argument list, Luiz Capitulino, 2012/03/29