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 B1D12424C1; Mon, 10 Jun 2024 18:11:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4317B402CA; Mon, 10 Jun 2024 18:11:12 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D115D402A9 for ; Mon, 10 Jun 2024 18:11:10 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id C48AC20B915A; Mon, 10 Jun 2024 09:11:09 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C48AC20B915A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1718035869; bh=0zFzqdXYg9uJeKxJ4ZQzWGOMnT6FKSeq1MKsZfKUSl0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nmfTgnLwYkg9V8gpf8BlVlKKEQ3kJtYOfTMOpMcux+Bhu57VgyxQ40g6bInsP6O/6 Wvd4NuIcp0AA+EIg7GRVA5CvRtCI00hTkygjbnqMPBjOF9NYMAbCIugs3ytHXOl4oP aeiZLgz5mXBQv56R5dtiDuQeKTsGkxYZIumcTRys= Date: Mon, 10 Jun 2024 09:11:09 -0700 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org Subject: Re: Coding Style for local variables Message-ID: <20240610161109.GA26737@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <98CBD80474FA8B44BF855DF32C47DC35E9F512@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F512@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Mon, Jun 10, 2024 at 05:10:01PM +0200, Morten Brørup wrote: > 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? +1 yes please