Skip to content

Commit

Permalink
Fix : Wrong _tcp_client[] array initialization
Browse files Browse the repository at this point in the history
Former "_tcp_client[MAX_CLIENT] = {};" tries to initialize
the array element with index MAX_CLIENT,
which is out of array range [0 .. (MAX_CLIENT-1)]
Fixes warning:
warning: array subscript 32 is above array bounds of 'tcp_struct* [32]'
[-Warray-bounds]

Instead initialize each element of the array one by one.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
  • Loading branch information
ABOSTM committed Apr 13, 2022
1 parent e2e0a42 commit 0384dd2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/EthernetServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ extern "C" {
EthernetServer::EthernetServer(uint16_t port)
{
_port = port;
_tcp_client[MAX_CLIENT] = {};
for (int i = 0; i < MAX_CLIENT; i++) {
_tcp_client[i] = {};
}
_tcp_server = {};
}

Expand Down

0 comments on commit 0384dd2

Please sign in to comment.