Fix dangling pointers and error message regressions
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJXIazvAAoJEDhwtADrkYZTMpUP/RpYwMtmGaREIpNxlfGIWwiH sYW/QY/cEVloozc6X9HkJzZ/EQgb2fA01dvVOL/UA8kshvCpZHdvIpblCzhuv0ZL Zj1zm7a6OYDCQZyNwNVAALxd+kVxJF+CGu15JczHiz3L1asVqejufoeOnq9bZPf1 /zowlMiNXj5oTdP3YkAcC+YXwJHeSwLDSDurwCQOYfvIdGRhbdUY1RhkcDvx8ch8 h9OtcZy9wIUcYxv3LdGizp6kTCd025VDwHTYNKRQqR0Ge3V7dhoZSK9Z89vi+5FG Tj5E2vLeAcWH4Ha+omIQ8Xll5E0FdIbWktri4KVEPyr2/tC3T0XQSGIrZLGnaK/p AEwDLQCgpeVOCIgn02fYrPFhH2vjYl0qOigkyGIgjaNxLtfBCuIqZgsEKXOco4IX 3akKM8sy2FFYLVjfMm2EmpFRrPiiAFChdgyTUdvFHJvlmmk8/PBVMiTNC1p1BNFa qml9VitI3BfWE671YHjUXjX8lVAA/noRYpxruWJ+7Q0UrCH5N4zOrlgh7NdWla+I 6eJEYKBvcFwDTxHm2F5xpgqwJBPQ6DI6A5iPONAtXWL3XoT76IDyEDQC/ZLDc0P1 02itvuRVNdawj5vUR/Y0UKjnKz2rPGPeeYubTLeVTqwZsbD+iAcldJTQ/YWRIgCY Zks5CHUaz0DPkqKrXhZU =0UFQ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2016-04-28' into staging Fix dangling pointers and error message regressions # gpg: Signature made Thu 28 Apr 2016 07:25:51 BST using RSA key ID EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" * remotes/armbru/tags/pull-error-2016-04-28: qom: -object error messages lost location, restore it replay: Fix dangling location bug in replay_configure() QemuOpts: Fix qemu_opts_foreach() dangling location regression Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
736f85d5db
@ -140,7 +140,7 @@ typedef bool (*user_creatable_add_opts_predicate)(const char *type);
|
||||
* user_creatable_add_opts_foreach:
|
||||
* @opaque: a user_creatable_add_opts_predicate callback or NULL
|
||||
* @opts: options to create
|
||||
* @errp: if an error occurs, a pointer to an area to store the error
|
||||
* @errp: unused
|
||||
*
|
||||
* An iterator callback to be used in conjunction with
|
||||
* the qemu_opts_foreach() method for creating a list of
|
||||
@ -148,8 +148,9 @@ typedef bool (*user_creatable_add_opts_predicate)(const char *type);
|
||||
*
|
||||
* The @opaque parameter can be passed a user_creatable_add_opts_predicate
|
||||
* callback to filter which types of object are created during iteration.
|
||||
* When it fails, report the error.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
* Returns: 0 on success, -1 when an error was reported.
|
||||
*/
|
||||
int user_creatable_add_opts_foreach(void *opaque,
|
||||
QemuOpts *opts, Error **errp);
|
||||
|
39
qemu-img.c
39
qemu-img.c
@ -435,8 +435,7 @@ static int img_create(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -598,7 +597,6 @@ static int img_check(int argc, char **argv)
|
||||
bool writethrough;
|
||||
ImageCheck *check;
|
||||
bool quiet = false;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
|
||||
fmt = NULL;
|
||||
@ -679,8 +677,7 @@ static int img_check(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -871,8 +868,7 @@ static int img_commit(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1133,7 +1129,6 @@ static int img_compare(int argc, char **argv)
|
||||
int64_t nb_sectors;
|
||||
int c, pnum;
|
||||
uint64_t progress_base;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
|
||||
cache = BDRV_DEFAULT_CACHE;
|
||||
@ -1201,8 +1196,7 @@ static int img_compare(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
ret = 2;
|
||||
goto out4;
|
||||
}
|
||||
@ -1864,8 +1858,7 @@ static int img_convert(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
goto fail_getopt;
|
||||
}
|
||||
|
||||
@ -2299,7 +2292,6 @@ static int img_info(int argc, char **argv)
|
||||
bool chain = false;
|
||||
const char *filename, *fmt, *output;
|
||||
ImageInfoList *list;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
|
||||
fmt = NULL;
|
||||
@ -2363,8 +2355,7 @@ static int img_info(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2513,7 +2504,6 @@ static int img_map(int argc, char **argv)
|
||||
int64_t length;
|
||||
MapEntry curr = { .length = 0 }, next;
|
||||
int ret = 0;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
|
||||
fmt = NULL;
|
||||
@ -2573,8 +2563,7 @@ static int img_map(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2717,8 +2706,7 @@ static int img_snapshot(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &err)) {
|
||||
error_report_err(err);
|
||||
NULL, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2867,8 +2855,7 @@ static int img_rebase(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3133,7 +3120,6 @@ static int img_resize(int argc, char **argv)
|
||||
bool quiet = false;
|
||||
BlockBackend *blk = NULL;
|
||||
QemuOpts *param;
|
||||
Error *local_err = NULL;
|
||||
|
||||
static QemuOptsList resize_options = {
|
||||
.name = "resize_options",
|
||||
@ -3204,8 +3190,7 @@ static int img_resize(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3297,7 +3282,6 @@ static int img_amend(int argc, char **argv)
|
||||
bool quiet = false, progress = false;
|
||||
BlockBackend *blk = NULL;
|
||||
BlockDriverState *bs = NULL;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
|
||||
cache = BDRV_DEFAULT_CACHE;
|
||||
@ -3365,8 +3349,7 @@ static int img_amend(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
ret = -1;
|
||||
goto out_no_progress;
|
||||
}
|
||||
|
@ -534,8 +534,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_error)) {
|
||||
error_report_err(local_error);
|
||||
NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -711,8 +711,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (qemu_opts_foreach(&qemu_object_opts,
|
||||
user_creatable_add_opts_foreach,
|
||||
NULL, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
NULL, NULL)) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,7 @@ int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
bool (*type_predicate)(const char *) = opaque;
|
||||
Object *obj = NULL;
|
||||
Error *err = NULL;
|
||||
const char *type;
|
||||
|
||||
type = qemu_opt_get(opts, "qom-type");
|
||||
@ -178,8 +179,9 @@ int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
obj = user_creatable_add_opts(opts, errp);
|
||||
obj = user_creatable_add_opts(opts, &err);
|
||||
if (!obj) {
|
||||
error_report_err(err);
|
||||
return -1;
|
||||
}
|
||||
object_unref(obj);
|
||||
|
@ -275,7 +275,7 @@ void replay_configure(QemuOpts *opts)
|
||||
rr = qemu_opt_get(opts, "rr");
|
||||
if (!rr) {
|
||||
/* Just enabling icount */
|
||||
return;
|
||||
goto out;
|
||||
} else if (!strcmp(rr, "record")) {
|
||||
mode = REPLAY_MODE_RECORD;
|
||||
} else if (!strcmp(rr, "replay")) {
|
||||
@ -293,6 +293,7 @@ void replay_configure(QemuOpts *opts)
|
||||
|
||||
replay_enable(fname, mode);
|
||||
|
||||
out:
|
||||
loc_pop(&loc);
|
||||
}
|
||||
|
||||
|
@ -1108,19 +1108,19 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
|
||||
{
|
||||
Location loc;
|
||||
QemuOpts *opts;
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
loc_push_none(&loc);
|
||||
QTAILQ_FOREACH(opts, &list->head, next) {
|
||||
loc_restore(&opts->loc);
|
||||
rc = func(opaque, opts, errp);
|
||||
if (rc) {
|
||||
return rc;
|
||||
break;
|
||||
}
|
||||
assert(!errp || !*errp);
|
||||
}
|
||||
loc_pop(&loc);
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static size_t count_opts_list(QemuOptsList *list)
|
||||
|
6
vl.c
6
vl.c
@ -4291,8 +4291,7 @@ int main(int argc, char **argv, char **envp)
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("object"),
|
||||
user_creatable_add_opts_foreach,
|
||||
object_create_initial, &err)) {
|
||||
error_report_err(err);
|
||||
object_create_initial, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -4410,8 +4409,7 @@ int main(int argc, char **argv, char **envp)
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("object"),
|
||||
user_creatable_add_opts_foreach,
|
||||
object_create_delayed, &err)) {
|
||||
error_report_err(err);
|
||||
object_create_delayed, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user