From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 003124548F; Thu, 20 Jun 2024 02:38:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF94F402A3; Thu, 20 Jun 2024 02:38:14 +0200 (CEST) Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) by mails.dpdk.org (Postfix) with ESMTP id 04A9940273 for ; Thu, 20 Jun 2024 02:38:12 +0200 (CEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 5FC4711401D0; Wed, 19 Jun 2024 20:38:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 19 Jun 2024 20:38:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1718843892; x=1718930292; bh=LPb1Fbto9M0FWxc0JgN3nC0bJHrzsKAY/cfwb+dJAOs=; b= gnBthQEpOYHt+oO/yoUU6hO62XyimBMNrRoSKF1dlaKz6jrIKn7/v/9YjEEXaKBP e2/t3+bxnJq3yc4os81616kN7cbALH4q3lqkL5L9btMZ/wdzszW8j7mjisGvConC xlVrfwzgy0E8v/M4T6g+di5LV6+EfUZwmrnuueQQWLBShMJkDjBD+/auG3jyw9tU Tvvrbno9BLmWBwjygK/x1gdgE3Re/3FxLruv1IW9r8H+cYBfH5R/bMqOSLFufaKH EJDbgdIImvEXyKpq2oTCjr2Gs/w7rSwIJbaUUj/HSLy6QTDEqSMvQ4KrbaoZd6tr 4jSlxORLvbYrKFny7CSa2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1718843892; x= 1718930292; bh=LPb1Fbto9M0FWxc0JgN3nC0bJHrzsKAY/cfwb+dJAOs=; b=e A2tmJ6GX9VrO6yfqktF4+wCHGgF2CJ+7X+UfcwInAXhN+EnRNLvtDblGTQTtRjws mJAsuqnrLjTdTAtMcG3lCsz/yKmt7OWYnz5HGImgcbQ51inhPbp7PANPJovBMCXf aH7Y488o+1UCifTBDfLHXF0OhmGiUEM3XLecc8KDbw1A6XhaooZ7mwUbmUUnglpi ADq8zTjYiMDn7/bALxTPMDklWKB60/cBnll+elTEiRO5KzxbIn1yJoEb1VBKzo4C pgegEexkX5fIqmSWyREjENCGP9dukkPDcL281t3/K1TPipOypbNzKz6uQron+hDu hg7j00Am2ujA6j+7yMmCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefuddgfeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpeejudevheeiveduuddtveffgfdtgeekueevjeffjeegtdeggeek gfdvuefgfeekjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 19 Jun 2024 20:38:10 -0400 (EDT) From: Thomas Monjalon To: Morten =?ISO-8859-1?Q?Br=F8rup?= Cc: "dev@dpdk.org" , Konstantin Ananyev , ferruh.yigit@amd.com, stephen@networkplumber.org, bruce.richardson@intel.com, david.marchand@redhat.com Subject: Re: Coding Style for local variables Date: Thu, 20 Jun 2024 02:38:03 +0200 Message-ID: <2579488.yFuDdFVEAc@thomas> In-Reply-To: <722d00ff8ec9497a92b831cfd13475d5@huawei.com> References: <98CBD80474FA8B44BF855DF32C47DC35E9F512@smartserver.smartshare.dk> <722d00ff8ec9497a92b831cfd13475d5@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 10/06/2024 18:31, Konstantin Ananyev: > Morten said: > > The coding style guide says: > > > > "Variables should be declared at the start of a block of code rather than in the middle. The exception to this is when the variable is > > const in which case the declaration must be at the point of first use/assignment. Declaring variable inside a for loop is OK." > > > > Since DPDK switched to C11, variables can be declared where they are used, which reduces the risk of using effectively uninitialized > > variables. "Effectively uninitialized" means initialized to 0 or NULL where declared, to silence any compiler warnings about the use of > > uninitialized variables. > > > > Can we please agree to remove the recommendation/requirement to declare variables at the start of a block of code? > > I know that modern C standards allow to define variable in the middle. > But I am strongly opposed to allow that in DPDK coding style. > Such practice makes code much harder to read and understand (at least for me). Yes it is convenient to know that all variables are described in a known place, just after function parameters. There is also a consistency concern. Old contributors like to be in a comfort zone, and we don't want to lose old contributors. New contributors may be refrained by old rules, and we would like to get more new contributors. So that's a tricky decision.