[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: Xen Coding style and clang-format
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |