[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/3] qapi: clear given pointer
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] qapi: clear given pointer |
Date: |
Wed, 21 Sep 2016 17:24:06 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> Some getters already set *obj argument to NULL early, let's do this for
> all for consistent behaviour in case of errors.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> qapi/qmp-input-visitor.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
> index ea9972d..cb9d196 100644
> --- a/qapi/qmp-input-visitor.c
> +++ b/qapi/qmp-input-visitor.c
> @@ -322,11 +322,13 @@ static void qmp_input_type_str(Visitor *v, const char
> *name, char **obj,
> QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
> QString *qstr = qobject_to_qstring(qobj);
>
> + if (obj) {
> + *obj = NULL;
> + }
> if (!qobj) {
> return;
> }
> if (!qstr) {
> - *obj = NULL;
> error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
> "string");
> return;
This undoes damage done in PATCH 1.
> @@ -368,6 +370,9 @@ static void qmp_input_type_any(Visitor *v, const char
> *name, QObject **obj,
> QmpInputVisitor *qiv = to_qiv(v);
> QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
>
> + if (obj) {
> + *obj = NULL;
> + }
> if (!qobj) {
> return;
> }
Likewise.
Similar damage done to qmp_input_start_list() and possibly others.
Please squash into PATCH 1 and double-check your new error returns affect
*obj like the existing ones.