Subject: Re: Warning from ring buffer code (Was: Re: linux-next: tip tree build warning)

From: Christopher Li <[email-masked]>
Date: Mon, 14 Sep 2009 10:09:27 -0700

On Mon, Sep 14, 2009 at 8:16 AM, Steven Rostedt <[email-masked]> wrote:
> static void func(int size_me) {
>        char array[size_me];
>
>        memcpy(array, "hello", size);
> };
>
> and sparse failed on it as well. Note, you need to have something call
> func, or sparse will ignore it.

Gcc allows variable size. Sparse expects the size of an array is constant.
For the kernel using variable array size is consider bad. Because the kernel
has very limited stack size. (8K if I remember correctly). Using dynamic array
is very easy to overflow the stack without realizing it.

It deserves a warning. I agree the warning message can use a better description
though.

Chris