From patchwork Thu May 2 18:58:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1094520 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44w4XT0TBbz9s9G for ; Fri, 3 May 2019 05:07:53 +1000 (AEST) Received: from localhost ([127.0.0.1]:57468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMH3e-00028V-Sq for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 15:07:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMGvw-0003vW-B2 for qemu-devel@nongnu.org; Thu, 02 May 2019 14:59:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hMGvv-0003G5-6g for qemu-devel@nongnu.org; Thu, 02 May 2019 14:59:52 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:43817) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hMGvp-00037H-V9; Thu, 02 May 2019 14:59:47 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MpDa5-1gyQDg3Xkl-00qlx4; Thu, 02 May 2019 20:58:48 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 20:58:24 +0200 Message-Id: <20190502185835.15185-3-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502185835.15185-1-laurent@vivier.eu> References: <20190502185835.15185-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:6WagXE00vi4QQwZmMsAKXeAEG8kmGBrv5XeQQE+7L0RCxCtE7Js jq6jbWP61ZHHNq+v7NLOMfdcrnu28ZBfEYOWFS5ovRmHItkypDs/yRNfjbxEFe6/hZTCs01 fVuG1JxM86snyRsthdUTLnSKry+a6IttZgcISmGu4hkyFaLckwTWhxkpSGWbdACHR34MT8s GYoZu6M4d3REkxe8o2p6g== X-UI-Out-Filterresults: notjunk:1; V03:K0:4gERy3jqQls=:n7b7aYxZ6tzSKomNnFGpSP H7CApcDXg6j5EC7aTR8gunAfjZXEQFVpei4LS0pSyZf2DGadLpWE8LDfBHW7/zpofrergnfTx PpRtm3BL0Q5kRNLVCiY2gpRhOnj1IE2N+4bmro4ZBcJNeSRDbaL7w87VkQC+u9Z6dpxzAfMHS ib7c5IdfIhOXxQ/xNWIlCVNMvXFBkjL6p/5xym3kpl9t0YVFrgEi/yFIx6qcM/mGysbMY7pcK cRs46XQqLV01c9HbHVRHo0L26v16YQD5zUfYq04zsrVqhmamfE3C1QiZ4VJAUoIBuvZo2keJ7 G7DVz48DOzk05M5D/FsZSLPGomBQ7nkVP2+n0x8Wqq7TFA8a4E7D1Z6Bz3Z17XMN67FWQmPc9 xieFXWlzXDwvfcnNVzf+7tSL4a6SD6VddfMRzrb66kP0DYq8BuduJTHwIs9iCowlVxWQuFsPg 40XD0oh+AIMcwQJH+DLhL/DwTYXTb2TAEWpzKPe91+vVdrGh91309V+c3SexmkARzoiLEFnoJ INTRcBeWLdEFgJkxoy23wILmuQU5DzgmTUcNSgNQmvejHOk+gVtYkav0lniIhRpbZgVgPlJPe byNLtKf8CjqFnr56sM+tVEGWzw3bSB0fUBsZy6Yr79GliJMzBGnE6Pu2A8/ubdk2JF/Lf9/zB LrXYUtCrXwlNOOICAGa+hMyQuiFTe5oW8B4AE1qqT/pT95LeKZyK3tHl5r/cJTq1r875r5q7l CPMCB4RGcPt409+weCzOlFWNX5UdetFESeWEEw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.13 Subject: [Qemu-devel] [PULL 02/13] CODING_STYLE: specify the indent rule for multiline code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Michael Tokarev , Gerd Hoffmann , qemu-trivial@nongnu.org, Michael Roth , Artyom Tarasenko , Stefano Garzarella , Laurent Vivier , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , Fabien Chouteau , Igor Mammedov , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Viktor Prutyanov , Laurent Vivier , Wei Yang , Paolo Bonzini , =?utf-8?q?Andreas_F=C3=A4rber?= , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang We didn't specify the indent rule for multiline code here, which may mislead users. And in current code, the code use various styles. Add this rule in CODING_STYLE to make sure this is clear to every one. Signed-off-by: Wei Yang Suggested-by: Igor Mammedov Reviewed-by: Igor Mammedov Reviewed-by: Stefano Garzarella Message-Id: <20190304071631.27567-2-richardw.yang@linux.intel.com> Signed-off-by: Laurent Vivier --- CODING_STYLE | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CODING_STYLE b/CODING_STYLE index ec075dedc4a8..90321e9c2821 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -29,6 +29,45 @@ Spaces of course are superior to tabs because: Do not leave whitespace dangling off the ends of lines. +1.1 Multiline Indent + +There are several places where indent is necessary: + + - if/else + - while/for + - function definition & call + +When breaking up a long line to fit within line width, we need a proper indent +for the following lines. + +In case of if/else, while/for, align the secondary lines just after the +opening parenthesis of the first. + +For example: + + if (a == 1 && + b == 2) { + + while (a == 1 && + b == 2) { + +In case of function, there are several variants: + + * 4 spaces indent from the beginning + * align the secondary lines just after the opening parenthesis of the + first + +For example: + + do_something(x, y, + z); + + do_something(x, y, + z); + + do_something(x, do_another(y, + z)); + 2. Line width Lines should be 80 characters; try not to make them longer.