diff mbox

[v3,05/43] qapi: minor refactoring

Message ID 20170607163635.17635-6-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau June 7, 2017, 4:35 p.m. UTC
Use the more common pattern to error out.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qapi/qobject-input-visitor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Markus Armbruster June 8, 2017, 2:57 p.m. UTC | #1
Lets title this

    qapi: Clean up qobject_input_type_number() control flow

Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Use the more common pattern to error out.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qapi/qobject-input-visitor.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
> index eac40f618a..26ef49a60b 100644
> --- a/qapi/qobject-input-visitor.c
> +++ b/qapi/qobject-input-visitor.c
> @@ -547,13 +547,13 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
>      }
>  
>      qfloat = qobject_to_qfloat(qobj);
> -    if (qfloat) {
> -        *obj = qfloat_get_double(qobject_to_qfloat(qobj));
> +    if (!qfloat) {
> +        error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
> +                   full_name(qiv, name), "number");
>          return;
>      }
>  
> -    error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
> -               full_name(qiv, name), "number");
> +    *obj = qfloat_get_double(qobject_to_qfloat(qobj));
>  }
>  
>  static void qobject_input_type_number_keyval(Visitor *v, const char *name,

Preferably with the more descriptive commit message
Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox

Patch

diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index eac40f618a..26ef49a60b 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -547,13 +547,13 @@  static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
     }
 
     qfloat = qobject_to_qfloat(qobj);
-    if (qfloat) {
-        *obj = qfloat_get_double(qobject_to_qfloat(qobj));
+    if (!qfloat) {
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+                   full_name(qiv, name), "number");
         return;
     }
 
-    error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
-               full_name(qiv, name), "number");
+    *obj = qfloat_get_double(qobject_to_qfloat(qobj));
 }
 
 static void qobject_input_type_number_keyval(Visitor *v, const char *name,