qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] error: Remove NULL checks on error_propagate()


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] error: Remove NULL checks on error_propagate() calls
Date: Thu, 9 Jun 2016 14:11:23 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 06/09/2016 01:50 PM, Eduardo Habkost wrote:
> On Thu, Jun 09, 2016 at 01:37:23PM -0600, Eric Blake wrote:
> [...]
>>
>> Hmm - it seems like in most of the cases where the ONLY thing done in
>> the if (local_err) block is to propagate the error, we should instead be
>> directly assigning to errp instead of wasting a local variable.  At this
>> point, my review is repetitive enough that I'll stop looking, and leave
>> it up to you and Markus whether to attempt a more ambitious Coccinelle
>> script.
> 
> If it happens immediately before the function end or a return
> statement it should be easy, but it would still require some
> manual work to remove the unused variable declaration. Probably
> easier to do that in a follow-up patch.

I think Coccinelle can be used to eliminate unused local variables, but
don't know the recipe off-hand; maybe a web search will turn up something?

> 
> It's harder (impossible?) to make Coccinelle avoid matching if
> local_err is used somewhere else in the function. But it's
> probably doable with some manual work, in a follow-up patch.

I don't know - Coccinelle is rather powerful, and there may indeed be a
way to flag conditions for a variable that is not used anywhere except
in the lines mentioned in the recipe, vs. a variable that can also be
used in the ... portion of the recipe.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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