Re: [PATCH v2 16/16] Require K&R styled curly braces around function bodies

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

 



On Wed, Mar 19, 2014 at 12:18:56PM +0100, Martin Kletzander wrote:
> Although not explicitly requested, we are using K&R (or Kernel)
> indentation for curly braces around functions in HACKING file and most
> of the code.  Using grep -P, this patch add the syntax-check rule for
> it (while skipping all the false positives with foreach constructs).
> 
> Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
> ---
> 
> Notes:
>     Unfortunately, the regexp is meant to catch as much as possible and
>     thus one line functions must occupy two lines, e.g.:
>     
>     static inline int getuid(void) { return 0; }
>     
>     is not valid.  This can be changed by appending $$ to the end of the
>     regexp which I didn't want to do since it might not catch something
>     else I haven't thought of.

I think that's an acceptable limitation. We don't have many of those
single line functions, so it isn't worth worrying about them.

> diff --git a/cfg.mk b/cfg.mk
> index 7a65d1e..559f719 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -898,6 +898,13 @@ sc_prohibit_virConnectOpen_in_virsh:
>  	halt='Use vshConnect() in virsh instead of virConnectOpen*'    \
>  	  $(_sc_search_regexp)
> 
> +sc_curly_braces_style:
> +	@files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$');                \
> +	$(GREP) -nHP                                                   \
> +'^\s*(?!([a-zA-Z_]*for_?each[a-zA-Z_]*) ?\()([_a-zA-Z0-9]+( [_a-zA-Z0-9]+)* ?\()?(\*?[_a-zA-Z0-9]+(,? \*?[_a-zA-Z0-9\[\]]+)+|void)\) ?\{' \
> +	$$files && { echo '$(ME): Non-K&R style used for curly'        \
> +			  'braces around function body, see'           \
> +			  'HACKING' 1>&2; exit 1; } || :

ACK

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]