Re: [Qemu-block] [PATCH] error: Avoid redudant error_propagate() usage
On Thu, Jun 09, 2016 at 02:54:51PM -0600, Eric Blake wrote: > On 06/09/2016 02:47 PM, Eduardo Habkost wrote: > > On Thu, Jun 09, 2016 at 05:21:34PM -0300, Eduardo Habkost wrote: > >> This patch simplifies code that uses a local_err variable just to > >> immediately > >> use it for an error_propagate() call. > > > > Please ignore this one. I found a better way to tell Coccinelle > > to do that. Updated Coccinelle patch is below, but I will send > > the actual patch tomorrow. > > Cool. Worth sticking these in scripts/coccinelle/ as part of your > commit so that we can rerun them later (and refer to them for ideas when > writing new scripts)? I didn't know about scripts/coccinelle. I will do! -- Eduardo
Re: [Qemu-block] [PATCH] error: Avoid redudant error_propagate() usage
On 06/09/2016 02:21 PM, Eduardo Habkost wrote: > This patch simplifies code that uses a local_err variable just to immediately > use it for an error_propagate() call. > > Done using the following Coccinelle patch: > > +++ b/block.c > @@ -353,7 +353,6 @@ out: > int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp) > { > BlockDriver *drv; > -Error *local_err = NULL; > int ret; > > drv = bdrv_find_protocol(filename, true, errp); > @@ -361,8 +360,7 @@ int bdrv_create_file(const char *filename, QemuOpts > *opts, Error **errp) > return -ENOENT; > } > > -ret = bdrv_create(drv, filename, opts, _err); > -error_propagate(errp, local_err); > +ret = bdrv_create(drv, filename, opts, errp); > return ret; And I _know_ there's a Coccinelle recipe for further shortening this into 'return bdrv_create(...)' (since it was part of the tutorial class at last year's KVM Forum) - again, I don't know the actual syntax to use to get it, but it shouldn't be too hard to find in a web search. Fine as yet another followup patch. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [Qemu-block] [PATCH] error: Avoid redudant error_propagate() usage
On 06/09/2016 02:47 PM, Eduardo Habkost wrote: > On Thu, Jun 09, 2016 at 05:21:34PM -0300, Eduardo Habkost wrote: >> This patch simplifies code that uses a local_err variable just to immediately >> use it for an error_propagate() call. > > Please ignore this one. I found a better way to tell Coccinelle > to do that. Updated Coccinelle patch is below, but I will send > the actual patch tomorrow. Cool. Worth sticking these in scripts/coccinelle/ as part of your commit so that we can rerun them later (and refer to them for ideas when writing new scripts)? -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature