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

Xen Coding style and clang-format


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Anastasiia Lukianenko <Anastasiia_Lukianenko@xxxxxxxx>
  • Date: Wed, 30 Sep 2020 09:18:55 +0000
  • Accept-language: en-GB, 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=+en2vUmnSfrEQDW+5ajFkmlchYiLkAw/BRL9zRxswnA=; b=j4hgAkf74gMf6vHh7dPtZLcoZUeM0rmN6iYrJnTHlVDdRQuhVO6kz4qdzDPB4lXMlfmEIS8yPhX4fo3afE2CvxnrIemmjiNiY1vXfjfA6f9UKUwwkl1vzymZcQF+Bt9GKWE+rdeDU5Z/HhvAbCVpm0inOeCAxlx60GmpGIWPI3tTvNCIm0FNBdVyKo+CWaQb+gOBGtz40Xutx4ZEqRbpPVfUd3ygVIrAQPwLqwBHjsSku0cZSlQnqfYEDOj3pMInF378r1A0fochoRwOPekTVmo8PZtxxLpwBTXI9d4/Peqk5THSB6p7B+dWdLqCfOw51Wocc1tgijeFa/lw2ozsPA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NgvsGXPi3tGwXADXixORmba78SPKC2pRNXZ8ABjkia5HO68yR+uQYjcAuv2hnx0oc5vBh/6+vRX8g9z8jbA87s2KAs70WkTUfSXuNtoMkPXrnW+XoXACCUHel7Mqi5xUKVWUOg1LfVHeavRTiXeYFc9Ss0/51c9j81i5EYTOWpKGHCYxpPjPBSSLqTQpNadplh2iRYgD19bXe0Bk4cuva9ragvBt4sTXwXSrjYOOgub8xLzAnecKLSvxDJ8Xuhv1gMBVoKTdNBZll6P17xYG1b+ChR66JulJmRZ72RVBKSRprYbMGpSW7N4OVFq2K3BT7bg7Hjn8tIyth2Ek7B4IqA==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=epam.com;
  • Cc: Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "committers@xxxxxxxxxxxxxx" <committers@xxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "vicooodin@xxxxxxxxx" <vicooodin@xxxxxxxxx>, "viktor.mitin.19@xxxxxxxxx" <viktor.mitin.19@xxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 30 Sep 2020 09:39:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWlwq4nKYEhMN38U+xmvwRsutq+Q==
  • Thread-topic: Xen Coding style and clang-format

Hi all,

I would like to bring up a discussion about a Xen-checker tool, the
development of which has been temporarily suspended. The idea of this
tool is to use the clang-format approach as a base for Xen ‘checkpatch’
process. The new tool consists of modified clang-format binary and
modified clang-format-diff.py python script to automate Xen patches
format checking and reformatting. The tool can be used as a pre-commit
hook to check and format every patch automatically.
Xen checker is currently in a state of testing, but there are
controversial points regarding the coding style that I would like to
discuss with the community and make a unanimous decision on the
correctness of the formatting.

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)
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) )
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);         \
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
+     */

Please find below the repo created by Viktor Mitin with xen clang-
format under the next link (branch xen-clang-format):
https://github.com/xen-troops/llvm-project/tree/xen-clang-format

The next script can be used as an example of how to build clang-format:

https://github.com/viktor-mitin/xen-clang-format-example/blob/master/build_clang_format.sh

Regards,
Anastasiia Lukianenko

 


Rackspace

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