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

Re: [Xen-devel] [PATCH 2/2] CODING_STYLE: list further brace placement exceptions


  • To: Jan Beulich <JBeulich@xxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Fri, 19 Jul 2019 16:48:06 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=epam.com;dmarc=pass action=none header.from=epam.com;dkim=pass header.d=epam.com;arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D0L7iisJnfXsFzQeQGLNABlu+9clA9daDBWkOnb352g=; b=A17V+eUNWZeueUWglF2Z2pDUC7uM/2IAGg2TgR+QeBbJXvkrhBtmjLerr9X0rVEGTeBe9RDmZwJqTn2KclNsTc5EFm+v77GpSjyLben5nUq/xPnZNknMk1GYaiOBm72i3qbcQv0x4CspQqG5l0/sjTUi+UeedmRPlMGZLCLKIFv9fOn2drMvmb8smd10h0/2rxAGOXeXFjpQM2sRFfuruUM/2EYAu2jZdPOkTsjJ7S/Q3FTlbPeGGpaRReI6vi9FLBZ4oCFB4KUVmpO+kknoS6YkkHyGcm+tazl+ixniNjdvWgrD7hhG9SVgClvmQvcd9ADqBJyfOw5CLtedhoL11Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SFB0E8yi6mXchydUTFxZ4jR2ENiGHjjJvTe/j0t3qgV4xq7mtPWzNE9WJeN+GcabjUakQ+q7+POz12KJWMhxkH4lMKpWjX4nIMaiTu3JuDXHIg16VGuINtpx/JtRUhw9wNPe7lSF9Pt6cnvScp1JFqLiD2A8YGWJqgfcQWydU5Fgib8qEJEUx2/Bl+AlJoAL+tYOkUwEIPX1MXZ02dnV0y95GXzHSvqvE5zJHxJ/a9uvr1kXcK2cb8deCWqZkPkLO/ezF5K6U/cSQdYWdGs8J++6fBGQw2hrrsjwJCQ5Nzw03l9F3DSKwXmaWPdjWM2ukzpZe4L/Axa7THcthv9Uyw==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@xxxxxxxx;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Konrad Wilk <konrad.wilk@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, JulienGrall <julien.grall@xxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 19 Jul 2019 16:48:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVPhNEaDGDKqwi6ked7nxWCSuuuqbSJ1KA
  • Thread-topic: [Xen-devel] [PATCH 2/2] CODING_STYLE: list further brace placement exceptions

Hi Jan,

Jan Beulich writes:

> For easy spotting of struct/union/enum definitions we already commonly
> place the opening braces on the initial line of such a definition.
>
> We also often don't place the opening brace of an initializer on a
> separate line.
>
> And finally for compound literals placing the braces on separate lines
> often makes the code more difficult to read, so it should (and in
> practice does) typically go on the same line as well.  The placement of
> the closing brace often depends on how large such a compound literal is.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> TBD: We may want to make explicit that for initializers both forms are
>       fine.
>
> --- a/CODING_STYLE
> +++ b/CODING_STYLE
> @@ -64,8 +64,13 @@ Bracing
>   -------
>
>   Braces ('{' and '}') are usually placed on a line of their own, except
> -for the do/while loop.  This is unlike the Linux coding style and
> -unlike K&R.  do/while loops are an exception. e.g.:
> +for
> +- the do/while loop
> +- the opening brace in definitions of enum, struct, and union
> +- the opening brace in initializers
> +- compound literals
Looks like this leaves us only with "if/else", "for", "switch" and
various forms of "for_each_*". So maybe it is worth to rewrite this
in the opposite manner? Like this:

Braces ('{' and '}') are usually placed on the same line, except the
following cases:

 - if, else, for, switch statements
 - for_each_* iterators like for_each_vcpu

> +This is unlike the Linux coding style and unlike K&R.  do/while loops
There is extra space before "do/while".

> +are one exception. e.g.:
>
>   if ( condition )
>   {
>


--
Volodymyr Babchuk at EPAM
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.