From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 9E2B88E62 for ; Wed, 13 Jan 2016 16:07:15 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 13 Jan 2016 07:07:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,289,1449561600"; d="scan'208";a="880569271" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.208.64]) by fmsmga001.fm.intel.com with SMTP; 13 Jan 2016 07:07:09 -0800 Received: by (sSMTP sendmail emulation); Wed, 13 Jan 2016 15:07:08 +0025 Date: Wed, 13 Jan 2016 15:07:08 +0000 From: Bruce Richardson To: Yuanhan Liu Message-ID: <20160113150708.GD7756@bricha3-MOBL3> References: <1452671929-29617-1-git-send-email-yuanhan.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1452671929-29617-1-git-send-email-yuanhan.liu@linux.intel.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] doc: coding style: use linux kernel style for indentation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2016 15:07:16 -0000 On Wed, Jan 13, 2016 at 03:58:49PM +0800, Yuanhan Liu wrote: > Using two tabs for "if" (or "while") statements is a bit weird to me. > Also, using one tab unconditionaly for function definitions and > prototypes doesn't look great. > > Here I'd suggest to use the indentation style the Linux kernel > project prefers: to align with the open brace with tabs and > additonal spaces (when necessary). > > Example: > > static int > rte_eal_foo_bar(int a_long_argument_1, int another_long_argument_2, > struct foo *yet_another_long_argument_3) > > ret = rte_eal_foo_bar(a_long_argument_1, another_long_argument_2, > yet_another_long_argument_3); > > if (really_long_variable_name_1 == really_long_variable_name_2 && > var3 == var4) { > x = y + z; > ....; > } > > Cc: Thomas Monjalon > Cc: Siobhan Butler > Cc: John McNamara > Signed-off-by: Yuanhan Liu > --- While it's not a big deal - yet is something likely to trigger massive discussion my objections to this style of indentation is two-fold: 1. It means that we are using a mix of tabs and spaces for indentation at the start of a line. I think it's more consistent that all whitespace at the start of a line should be either tabs or spaces, but not a mixture. 2. It makes how the code look much more dependent upon the tab-size being used in the viewer - being able to adjust how much whitespace is seem at the start of each line is a major advantage of using tabs rather than spaces for indentation. For anyone using a 4-character tabstop - probably the most popular tabstop value after an 8-char one - aligning an if-statement continuation to the opening brace will cause it to align with the body of the block. So, while the two-tab indent may look "a bit weird" it does solve the two issues above. I believe practical benefits should override initial impressions. [It took me a while to get used to also, but now I very much like it as a style.] Regards, /Bruce