From patchwork Thu Jul 18 14:43:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 11049117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DA8113BD for ; Thu, 18 Jul 2019 14:44:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CAFF287C2 for ; Thu, 18 Jul 2019 14:44:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20331287CF; Thu, 18 Jul 2019 14:44:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1232A287C2 for ; Thu, 18 Jul 2019 14:44:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho7cx-0007kO-Vm; Thu, 18 Jul 2019 14:43:23 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho7cw-0007kJ-OU for xen-devel@lists.xenproject.org; Thu, 18 Jul 2019 14:43:22 +0000 X-Inumbo-ID: 63de6223-a96a-11e9-8980-bc764e045a96 Received: from mail-io1-f68.google.com (unknown [209.85.166.68]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 63de6223-a96a-11e9-8980-bc764e045a96; Thu, 18 Jul 2019 14:43:22 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id m24so51861988ioo.2 for ; Thu, 18 Jul 2019 07:43:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4h6hORWfsY6uu4me1CjMW8Zu+wBYhPWvFpHkD7dVcv8=; b=lHtnroL3L7r14QhUnYUgvCGwLgZGSxpnKBJseClRnp0kJtNp5zP9HO2Fovjqy55ztd 97rp1MVyKZBPnY2x+glux2ScyrXPqvWzn0Y090PSOXVQC4nFzCWHIobxvdQTzO9DvSfZ 1DgQEjSWy7DUnAFzT7GhmBvO+I6c8+eC2+dMknw1MW1BscR07T7qHLBCJgB5UO2Y5GJF SPkP8Kl4dTGWmddguxGDrYSlqe18YMRFYG2QYWHKovbXLCBZcnRGQqZSFoOg701x/+Hj mvFZoiofFhMECu7Wabp/7/BoY/CwKEJaLgzWyauU4RZBY/stpVFRHc3EqXlUqG6hdfdN AE9A== X-Gm-Message-State: APjAAAVIZrloL8zRVpJ+XDY44sbszDpayHuAVimJB5o5eXUZ8yTsXwih c31EhtmkjTHbEuiQkTvfkPXHnEOy X-Google-Smtp-Source: APXvYqyHU4lY78koz1iZ8w/9BtHUhm8HmrjcaCIdXn7UZfapfTSaqdJGwsMDm3zPcYYVAgfps+VUpw== X-Received: by 2002:a6b:1ca:: with SMTP id 193mr45224979iob.264.1563461001288; Thu, 18 Jul 2019 07:43:21 -0700 (PDT) Received: from l1.lan (c-71-205-12-124.hsd1.co.comcast.net. [71.205.12.124]) by smtp.gmail.com with ESMTPSA id t5sm23119176iol.55.2019.07.18.07.43.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 07:43:20 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Thu, 18 Jul 2019 08:43:17 -0600 Message-Id: <20190718144317.23307-1-tamas@tklengyel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Xen-devel] [RFC] xen: Add .astylerc for automated style-formatting X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Tamas K Lengyel , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Stefano Stabellini , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Using astyle (http://astyle.sourceforge.net) can greatly reduce the overhead of manually checking and applying style-fixes to source-code. The included .astylerc is the closest approximation of the established Xen style (including styles not formally spelled out by CODING_STYLE but commonly requested). Checking the comment styles are not included in the automation. Incorporating Xen's exception to the do-while style is only partially possible, thus a change is proposed to the CODING_STYLE of moving the brace from "do {" to the next line. Most of Xen's code-base is non-conforming at the moment: 289 files pass unchanged, 876 have some style issues. Ideally we can slowly migrate the entire code-base to be conforming, thus eliminating the need of discussing and enforcing style issues manually on the mailinglist. Signed-off-by: Tamas K Lengyel --- .astylerc | 14 ++++++++++++++ CODING_STYLE | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .astylerc diff --git a/.astylerc b/.astylerc new file mode 100644 index 0000000000..bbd1d55ddd --- /dev/null +++ b/.astylerc @@ -0,0 +1,14 @@ +style=bsd +suffix=none +align-pointer=name +align-reference=name +indent=spaces=4 +max-code-length=80 +min-conditional-indent=0 +attach-closing-while +remove-braces +indent-switches +break-one-line-headers +keep-one-line-blocks +pad-comma +pad-header diff --git a/CODING_STYLE b/CODING_STYLE index 6cc5b774cf..0b37f7ae4d 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -60,8 +60,8 @@ 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 while-part of do/while loops. This is unlike the Linux coding style +and unlike K&R. do/while loops are an exception. e.g.: if ( condition ) { @@ -77,7 +77,8 @@ while ( condition ) /* Do stuff. */ } -do { +do +{ /* Do stuff. */ } while ( condition ); @@ -120,3 +121,14 @@ the end of files. It should be: * indent-tabs-mode: nil * End: */ + +Automated style formatting using astyle +--------------------------------------- + +The .astylerc included in the Xen tree incorporates most of Xen's +style requirements, except the formatting of comments. + +The steps to automatically format a file are: + +export ARTISTIC_STYLE_OPTIONS=".astylerc" +astyle