23/03/2020 14:40, David Marchand:
> On Mon, Feb 17, 2020 at 11:27 PM Thomas Monjalon <tho...@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\)'
> 
> You missed size_t:
> drivers/common/mlx5/mlx5_glue.c:        for (size_t i = 0; i < num_actions; 
> i++)

Good catch, thanks.

[..]
> > --- a/devtools/checkpatches.sh
> > +++ b/devtools/checkpatches.sh
> > +       # forbid variable declaration inside "for" loop
> > +       awk -v FOLDERS='.' \
> > +               -v EXPRESSIONS='for *\\((char|u?int|unsigned)' \
> 
> + s?size_t

OK

> > +               -v RET_ON_FAIL=1 \
> > +               -v MESSAGE='Declaring a variable inside for()' \
> > +               -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
> > +               "$1" || res=1
> > +
> 
> Just a note, base drivers imported "as is" will probably trigger warnings.

Yes, base drivers don't comply with coding rules and trigger lots of warnings.



Reply via email to