From patchwork Fri May 3 11:19:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1094838 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 44wVMx1gzPz9s3Z for ; Fri, 3 May 2019 21:31:57 +1000 (AEST) Received: from localhost ([127.0.0.1]:38535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMWPz-0002YU-1I for incoming@patchwork.ozlabs.org; Fri, 03 May 2019 07:31:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMWF3-0000cg-D2 for qemu-devel@nongnu.org; Fri, 03 May 2019 07:20:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hMWF2-0002UF-D9 for qemu-devel@nongnu.org; Fri, 03 May 2019 07:20:37 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:52677) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hMWEz-0002Pv-Vy; Fri, 03 May 2019 07:20:34 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MiakT-1grbKw1aCd-00flhN; Fri, 03 May 2019 13:20:09 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 3 May 2019 13:19:48 +0200 Message-Id: <20190503111958.30825-3-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190503111958.30825-1-laurent@vivier.eu> References: <20190503111958.30825-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Mo0DHmSk3NXOQ39/99q/lX9tdbs4b1ZFlo11KKPGiKVH2+VmJKa 0Cd0YVYHpijJ3+gDGvWdA0yaN1yOXchrDhi8R9TF0CpCtKQZ74J+3AZ5sSFtOJ11UyNDoWk ovvZ4wElGnjhzG0t26GioGcRU0sXQNHtRlBX8+iFUv4Hux2QGV7e8Wu9ApYcvwVBtbqNQ5X xMBShRn2O39O56lK53mKQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:4D1AAZDHlv0=:xIB9Y2RHqtxeTDvzVQnygV +2vQhicwVLUHTHmfF5DqI3Sc/7CBJIYl3CxGx/K6FDd/hLrnckHr67zsMOB9THNQC8cANZnzD Qut8GjSpgd+FszRd9HRcisewgw3YmSay2ZIbTK3Elw7a8/F/vmHg5zf8q0YVVToAZRw+6bQd/ YEtC20znLRW6V7FryjeC1WxYE/mCKWMflbk9GV7V85c4KmA4sTsYfM4lwhp5190mS5IVNvSt+ VM9NTdDLxVYyrinqkSvRwMf79cp33mXiB1MqVNNyV8V9/buKXqak1F61hCqA8Xw+pxsSX0gnX zmKQuXQokWS6KIS7roXuCGRAGPtH89rmR5q7T7rpm8yx1DIvVD9JJbwBABHtstc83VaCtLyTl Y5NkTV44IqtMLy/tpypxjuLeZ/zEd3LvoaR1LiaclGdHXsw3Uz/aIBlCI76iRL7r0DW5WyzAM BKAhFSJCCmeIyJyRHmjM7JIWOnNewyTfObMHD8OWs6TzrKbA4WKt09a7tbbNFRGINScpItAl2 HXwgiVvjE8jqfXEJiXzGE1VIv/cEjUti4Deoq5gz3bGOANawGRKmbcE7sVQV8T4bexTDJ0Bjb dPGpSOtnIJew2LXd7fmH8awH7joTXOC29zre5BI8OE4/i9wWalx5nxlhOQkRR0VbbaMthwEwO hvvoV8jfIpVgO3GcFJFfooVAld/acsYPH1C/iP/8ZjbP1GDNY3cOfXE6/7PphPCO3IRUyTdP/ xrpXRnNzrYuDN5TcFNfZZpCp/GoK1V5WQ0k23w== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.74 Subject: [Qemu-devel] [PULL v2 02/12] 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: qemu-trivial@nongnu.org, Mark Cave-Ayland , Jason Wang , Michael Tokarev , Laurent Vivier , Fabien Chouteau , Michael Roth , Wei Yang , Gerd Hoffmann , Igor Mammedov , Paolo Bonzini , Stefano Garzarella , =?utf-8?q?Andreas_F=C3=A4rb?= =?utf-8?q?er?= , Artyom Tarasenko , Richard Henderson 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.