commit f2fe9206c6b10b6e7996957c3f4618c0ec81aced
parent 8a8c2fbe38b1b53ee4fba3e8db41b9a5312c3065
Author: James Prestwood <prestwoj@gmail.com>
Date: Fri, 10 Jun 2022 12:52:41 -0700
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
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/p2p.c b/src/p2p.c
@@ -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;