[libvirt] [PATCH 6/6] maint: enforce previous if-else {} cleanups

Eric Blake eblake at redhat.com
Thu Sep 4 14:59:42 UTC 2014


On 09/04/2014 05:26 AM, Peter Krempa wrote:
> On 09/03/14 23:25, Eric Blake wrote:
>> Done as a separate commit in case earlier cleanups are backported
>> independently.
>>
>> * cfg.mk (sc_require_space_before_label): New rule.
>>
>> Signed-off-by: Eric Blake <eblake at redhat.com>
>> ---
>>  cfg.mk | 7 +++++++
>>  1 file changed, 7 insertions(+)
> 
> Doesn't apply cleanly if your "hanging brace" series patch 2/2 is applied.

Well, I _did_ say in the cover letter to that series that this one goes
first :)  Just because you chose to review the low-hanging-fruit of the
shorter series first...

>>
>> +# Doesn't catch all cases of mismatched braces across if-else, but it helps
>> +sc_require_if_else_matching_braces:
>> +	@prohibit='(  else( if .*\))? {|} else( if .*\))?$$)'		\
>> +	in_vc_files='\.[chx]$$'						\
>> +	halt="if one side of if-else uses {}, both sides must use it"	\
>> +	  $(_sc_search_regexp)
> 
> Seems to do the right thing, but my regex-fu isn't that strong so I
> might have missed something.

Basically, the cases it doesn't catch are:

    if (...) {
        blah;
    } else if (... &&
               ...)
        blah;

or the counterpart

    if (...)
        blah;
    else if (... &&
             ...) {
        blah;
    }

where the if condition is broken across multiple lines (it only looks
for obvious cases detectable in a single line).  I can always submit a
followup patch later if I think of a bright way to handle that.

>> +
>>  sc_curly_braces_style:
>>  	@files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$');                \
>>  	$(GREP) -nHP                                                   \
>>
> 
> ACK

Thanks; I'll push the series shortly, after addressing your nits in
earlier patches.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140904/9446954f/attachment-0001.sig>


More information about the libvir-list mailing list