qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 28/44] qom: Use returned bool to check for failure, Coccin


From: Eric Blake
Subject: Re: [PATCH v2 28/44] qom: Use returned bool to check for failure, Coccinelle part
Date: Thu, 2 Jul 2020 12:31:16 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 7/2/20 10:49 AM, Markus Armbruster wrote:
The previous commit enables conversion of

     foo(..., &err);
     if (err) {
        ...
     }

to

     if (!foo(..., errp)) {
        ...
     }

for QOM functions that now return true / false on success / error.
Coccinelle script:

     @@
     identifier fun = {object_apply_global_props, 
object_initialize_child_with_props, object_initialize_child_with_propsv, 
object_property_get, object_property_get_bool, object_property_parse, 
object_property_set, object_property_set_bool, object_property_set_int, 
object_property_set_link, object_property_set_qobject, object_property_set_str, 
object_property_set_uint, object_set_props, object_set_propv, 
user_creatable_add_dict, user_creatable_complete, user_creatable_del};
     expression list args, args2;
     typedef Error;
     Error *err;
     @@
     -    fun(args, &err, args2);
     -    if (err)
     +    if (!fun(args, &err, args2))
          {
              ...
          }

Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.

Line breaks tidied up manually.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---

Reviewed-by: Eric Blake <eblake@redhat.com>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]