Make dl_list_first() and dl_list_last() uses easier for static analyzers

The previous check for dl_list_len() or having an entry from the list is
sufficient, but some static analyzers cannot figure out that
dl_list_first() and dl_list_last() will return non-NULL in this type of
cases. Avoid invalid reports by explicitly checking for NULL.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-04-26 11:43:25 +03:00
parent 5f693cb1b6
commit 0bceb8d6f4
5 changed files with 23 additions and 16 deletions

View file

@ -4210,7 +4210,7 @@ p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next)
dev = dl_list_first(&dev->list,
struct p2p_device,
list);
if (&dev->list == &p2p->devices)
if (!dev || &dev->list == &p2p->devices)
return NULL;
} while (dev->flags & P2P_DEV_PROBE_REQ_ONLY);
}
@ -4222,7 +4222,7 @@ p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next)
dev = dl_list_first(&dev->list,
struct p2p_device,
list);
if (&dev->list == &p2p->devices)
if (!dev || &dev->list == &p2p->devices)
return NULL;
}
}