[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK8P3a1Urc1tunFcd5vXybRpBGQ7tBVm5BC6qu3oEXM0C_NG4g@mail.gmail.com>
Date: Tue, 19 Feb 2019 22:50:39 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Nathan Chancellor <natechancellor@...il.com>
Cc: Remi Denis-Courmont <courmisch@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Networking <netdev@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>
Subject: Re: Clang warnings in net/phonet
On Tue, Jan 8, 2019 at 3:55 AM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> Hi all,
>
> When building the kernel with Clang, this warning comes up in net/phonet.
>
> net/phonet/pep.c:224:16: warning: array index 1 is past the end of the array (which contains 1 element) [-Warray-bounds]
> ph->data[0] = oph->data[1]; /* CTRL id */
> ^ ~
> include/net/phonet/pep.h:66:3: note: array 'data' declared here
> u8 data[1];
> ^
>
> I have taken a look at the effected code but I can't really figure out
> the proper fix for this warning (my knowledge of C just isn't there
> yet). Nick had suggested changing 'u8 data[1]' to 'u8 *data' in
> 'struct pnpipehdr', which seems logical but I can't say for sure. Any
> advice would be appreciated :)
>
A pointer wouldn't work here, as this is a network header with a
fixed layout. Using a flexible array at the end of the structure works,
but unfortunately all indices change that way. Sending an experimental
patch.
Arnd
Powered by blists - more mailing lists