xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Anastasiia Lukianenko <Anastasiia_Lukianenko@epam.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Artem Mygaiev <Artem_Mygaiev@epam.com>,
	"committers@xenproject.org" <committers@xenproject.org>,
	"julien@xen.org" <julien@xen.org>,
	"vicooodin@gmail.com" <vicooodin@gmail.com>,
	"viktor.mitin.19@gmail.com" <viktor.mitin.19@gmail.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: Xen Coding style and clang-format
Date: Wed, 30 Sep 2020 11:57:50 +0200	[thread overview]
Message-ID: <4238269c-3bf4-3acb-7464-3d753f377eef@suse.com> (raw)
In-Reply-To: <300923eb27aea4d19bff3c21bc51d749c315f8e3.camel@epam.com>

On 30.09.2020 11:18, Anastasiia Lukianenko wrote:
> I would like to know your opinion on the following coding style cases.
> Which option do you think is correct?
> 1) Function prototype when the string length is longer than the allowed
> one
> -static int __init
> -acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
> -                             const unsigned long end)
> +static int __init acpi_parse_gic_cpu_interface(
> +    struct acpi_subtable_header *header, const unsigned long end)

Both variants are deemed valid style, I think (same also goes for
function calls with this same problem). In fact you mix two
different style aspects together (placement of parameter
declarations and placement of return type etc) - for each
individually both forms are deemed acceptable, I think.

> 2) Wrapping an operator to a new line when the length of the line is
> longer than the allowed one
> -    if ( table->revision > 6
> -         || (table->revision == 6 && fadt->minor_revision >= 0) )
> +    if ( table->revision > 6 ||
> +         (table->revision == 6 && fadt->minor_revision >= 0) )

Only the latter variant is correct.

> 3) define code style
> -#define ALLREGS \
> -    C(r0,r0_usr);   C(r1,r1_usr);   C(r2,r2_usr);   C(r3,r3_usr);   \
> -    C(cpsr,cpsr)
> +#define ALLREGS            \
> +    C(r0, r0_usr);         \
> +    C(r1, r1_usr);         \
> +    C(r2, r2_usr);         \

You're again mixing multiple style aspects together: There definitely
should be a blank after the comma, but I don't think we require
every item to be on its own line. But this latter aspect is a little
bogus here anyway - generally, macros better wouldn't contain
embedded semicolons, unless e.g. in a compound statement.

I also don't think we require backslashes (not) to be aligned; this
has typically been left to the author's taste so far, I guess.

> 4) Comment style
> -    /* PC should be always a multiple of 4, as Xen is using ARM
> instruction set */
> +    /* PC should be always a multiple of 4, as Xen is using ARM
> instruction set
> +     */

For a single line comment, only the former variant is correct.
In a multi-line comment neither would be. But comment style is
described well in ./CODING_STYLE, I think, so I'm not sure why
the question arose in the first place.

Jan


  reply	other threads:[~2020-09-30  9:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30  9:18 Xen Coding style and clang-format Anastasiia Lukianenko
2020-09-30  9:57 ` Jan Beulich [this message]
2020-09-30 10:24   ` George Dunlap
2020-10-01  9:06     ` Anastasiia Lukianenko
2020-10-01 10:06       ` George Dunlap
2020-10-07 10:19         ` Anastasiia Lukianenko
2020-10-08  1:07           ` Stefano Stabellini
2020-10-12 14:37             ` Anastasiia Lukianenko
2020-10-12 18:09           ` George Dunlap
2020-10-13 12:30             ` Jan Beulich
2020-10-16  9:42               ` Anastasiia Lukianenko
2020-10-16 10:23                 ` Julien Grall
2020-10-16 11:37                   ` Artem Mygaiev
2020-10-19 18:07                     ` Stefano Stabellini
2020-10-20 17:13                       ` Julien Grall
2020-10-23  9:39                         ` Anastasiia Lukianenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4238269c-3bf4-3acb-7464-3d753f377eef@suse.com \
    --to=jbeulich@suse.com \
    --cc=Anastasiia_Lukianenko@epam.com \
    --cc=Artem_Mygaiev@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=committers@xenproject.org \
    --cc=julien@xen.org \
    --cc=vicooodin@gmail.com \
    --cc=viktor.mitin.19@gmail.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).