[dpdk-dev] [PATCH v2] devtools: forbid variable declaration inside for

Stephen Hemminger stephen at networkplumber.org
Sun May 24 20:30:41 CEST 2020


On Sun, 24 May 2020 19:30:07 +0200
Thomas Monjalon <thomas at monjalon.net> wrote:

> Some compilers raise an error when declaring a variable
> in the middle of a function. This is a C99 allowance.
> Even if DPDK switches globally to C99 or C11 standard,
> the coding rules are for declarations at the beginning
> of a block:
> http://doc.dpdk.org/guides/contributing/coding_style.html#local-variables
> 
> This coding style is enforced by adding a check of
> the common patterns like "for (int i;"
> 
> The occurrences of the checked pattern are fixed:
> 	'for *(\(char\|u\?int\|unsigned\|s\?size_t\)'
> In the file dpaa2_sparser.c, the fix is to remove the unused macros.
> 
> Signed-off-by: Thomas Monjalon <thomas at monjalon.net>

Surprised that checkpatch doesn't enforce this already.
Or maybe kernel flags are different.



More information about the dev mailing list