3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-21 22:09:23 +01:00

p2p: fix warning for uninitialized variable (clang)

This is actually a false positive only because
p2p_device_validate_conn_wfd bails out if the IE is NULL which
avoids using wfd_data_length. But its subtle and without inspecting
the code it does seem like the length could be used uninitialized.

src/p2p.c:940:7: error: variable 'wfd_data_len' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                if (dev->conn_own_wfd)
                    ^~~~~~~~~~~~~~~~~
src/p2p.c:946:8: note: uninitialized use occurs here
                                                        wfd_data_len))
                                                        ^~~~~~~~~~~~
src/p2p.c:940:3: note: remove the 'if' if its condition is always true
                if (dev->conn_own_wfd)
                ^~~~~~~~~~~~~~~~~~~~~~
src/p2p.c:906:23: note: initialize the variable 'wfd_data_len' to silence this warning
                ssize_t wfd_data_len;
                                    ^
                                     = 0
This commit is contained in:
James Prestwood 2022-06-10 12:52:41 -07:00 committed by Denis Kenzior
parent 8a8c2fbe38
commit f2fe9206c6

View File

@ -903,7 +903,7 @@ static void p2p_group_event(enum ap_event_type type, const void *event_data,
{
const struct ap_event_station_added_data *data = event_data;
L_AUTO_FREE_VAR(uint8_t *, wfd_data) = NULL;
ssize_t wfd_data_len;
ssize_t wfd_data_len = 0;
struct p2p_association_req req_info;
int r;