From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id F1AD9424C1;
	Mon, 10 Jun 2024 18:31:57 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7EE83402CA;
	Mon, 10 Jun 2024 18:31:57 +0200 (CEST)
Received: from frasgout.his.huawei.com (frasgout.his.huawei.com
 [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 46AA7402A9
 for <dev@dpdk.org>; Mon, 10 Jun 2024 18:31:56 +0200 (CEST)
Received: from mail.maildlp.com (unknown [172.18.186.231])
 by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Vycf24R65z6JB5J;
 Tue, 11 Jun 2024 00:27:22 +0800 (CST)
Received: from frapeml100005.china.huawei.com (unknown [7.182.85.132])
 by mail.maildlp.com (Postfix) with ESMTPS id 9339F140AE5;
 Tue, 11 Jun 2024 00:31:55 +0800 (CST)
Received: from frapeml500007.china.huawei.com (7.182.85.172) by
 frapeml100005.china.huawei.com (7.182.85.132) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2507.39; Mon, 10 Jun 2024 18:31:55 +0200
Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by
 frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.039;
 Mon, 10 Jun 2024 18:31:55 +0200
From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: =?iso-8859-1?Q?Morten_Br=F8rup?= <mb@smartsharesystems.com>,
 "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: Coding Style for local variables
Thread-Topic: Coding Style for local variables
Thread-Index: Adq7SEPoIrinBLT+QHOLQL6ebOrFXAACwQRA
Date: Mon, 10 Jun 2024 16:31:55 +0000
Message-ID: <722d00ff8ec9497a92b831cfd13475d5@huawei.com>
References: <98CBD80474FA8B44BF855DF32C47DC35E9F512@smartserver.smartshare.dk>
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F512@smartserver.smartshare.dk>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.81.199.1]
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org



> The coding style guide says:
>=20
> "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/ass=
ignment. Declaring variable inside a for loop is OK."
>=20
> 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 whe=
re declared, to silence any compiler warnings about the use of
> uninitialized variables.
>=20
> Can we please agree to remove the recommendation/requirement to declare v=
ariables 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 m=
e).
Konstantin =20
=20