phonet: fix building with clang
authorArnd Bergmann <arnd@arndb.de>
Tue, 19 Feb 2019 21:53:50 +0000 (22:53 +0100)
committerivanmeler <i_ivan@windowslive.com>
Wed, 13 Apr 2022 21:13:44 +0000 (21:13 +0000)
commit59ee31aac69f80700c6a93a105b78e0db302ed64
tree494877c67262f875ba34e4658b3547896ce7b242
parent01bec25fefe33c2ba79e56b804739e210d45579e
phonet: fix building with clang

[ Upstream commit 6321aa197547da397753757bd84c6ce64b3e3d89 ]

clang warns about overflowing the data[] member in the struct pnpipehdr:

net/phonet/pep.c:295:8: warning: array index 4 is past the end of the array (which contains 1 element) [-Warray-bounds]
                        if (hdr->data[4] == PEP_IND_READY)
                            ^         ~
include/net/phonet/pep.h:66:3: note: array 'data' declared here
                u8              data[1];

Using a flexible array member at the end of the struct avoids the
warning, but since we cannot have a flexible array member inside
of the union, each index now has to be moved back by one, which
makes it a little uglier.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: RĂ©mi Denis-Courmont <remi@remlab.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/phonet/pep.h
net/phonet/pep.c