[dpdk-dev] [PATCH] eal: remove variable length array

Jeff Shaw jeffrey.b.shaw at intel.com
Fri Dec 14 20:07:13 CET 2018


On Fri, Dec 14, 2018 at 07:36:38PM +0100, Mattias Rönnblom wrote:
> On 2018-12-14 17:38, Jeff Shaw wrote:
> > Compilers that do not support the C11 standard, or do not implement
> > gcc extensions, may not support variable length arrays.
> > 
> 
> VLAs are a C99 thing.

You're right, my mistake.

> 
> > The code prior to this commit produced the following warning when
> > compiled with "-Wvla -std=c90".
> > 
> >    warning: ISO C90 forbids variable length array ‘array’ [-Wvla]
> > 
> > This commit removes the variable length array from the PMD debug
> > trace function by allocating memory dynamically on the stack using
> > alloca().
> > 
> 
> Is alloca() even included in *any* C standard? As far as I see, it just
> achieves the same thing in an uglier, less portable way than VLAs.

I agree that it is much less elegant than a VLA. This is in preparation
for DPDK on Windows, which using the Microsoft Visual C++ (MSVC) compiler.
MSVC does not support variable length arrays. It does, however, support
alloca(), as does GCC/ICC.

For this particular instance, the point is moot, since the function is
not used anywhere and can just as easily be removed. Though it does not
address the issue for the ~100 other instances where VLAs are used. We
will be submitting patches for those as more common files are ported to
Windows.


More information about the dev mailing list